Skip to main content
Installation Guides

Install on Shopify

Add Cromojo to your Shopify store's theme

Written By David

Last updated 1 day ago

Shopify lets you edit your theme's code directly. You'll paste your Cromojo script into the theme.liquid file so it loads on every page of your store.

Add the script

  1. In Cromojo, go to Settings → Analytics and click Copy to copy your tracking script.

The Analytics script section in Settings > Analytics, with the copy icon
  1. In Shopify admin, go to Online Store → Themes.

  2. On your current theme, click the … (three dots) → Edit code.

  3. In the Layout folder, open theme.liquid.

  4. Paste your script just before the closing </head> tag.

  5. Click Save.

Verify

Visit your store, then in Cromojo open Settings > Analytics and click Verify Installation, or watch for your visit to appear on the dashboard within a minute or two.

Settings > Analytics after verifying, showing Script installed

Track purchases on the thank-you page (recommended)

Shopify's checkout and thank-you pages don't use your theme, so the script above doesn't run there. Cromojo still links each order back to the original visit: the script saves the visit on the cart, and Shopify carries it through to the order. To also count the purchase as an event (for example as the last step of a funnel), add a small pixel:

  1. In Shopify admin, go to Settings > Customer events.

  2. Click Add custom pixel and name it "Cromojo".

  3. Paste this code, replacing the three values with the ones from your Cromojo snippet:

analytics.subscribe('checkout_completed', (event) => {
  const checkout = event.data.checkout;
  const attrs = checkout.customAttributes || [];
  const found = attrs.find((a) => a.key === 'cromojo_session_id');

  const script = document.createElement('script');
  script.src = 'https://YOUR-CROMOJO-SCRIPT-ADDRESS/script.min.js';
  script.setAttribute('data-site-id', 'sxxxxxxxxxxxxxxxxxxxxxxx');
  script.setAttribute('data-ingest-key', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
  script.setAttribute('data-forwarded-session', found ? found.value : '');
  script.addEventListener('load', () => {
    window.CRMJ.trackEvent('purchase', {
      value: checkout.totalPrice.amount,
      currency: checkout.currencyCode,
    });
  });
  document.head.appendChild(script);
});
  1. Click Save, then Connect.

Without this pixel your revenue is still attributed (once Shopify is connected), but a funnel that ends in "purchase" can show 0.

Good to know

  • Add the script in theme.liquid once. If you also add it through an app or Google Tag Manager, remove the duplicate.

  • Connect Shopify in Settings > Analytics > Conversion Metrics to see revenue per page, source and keyword.

→ Back to all installation guides