Skip to content
Skip to main content
European Data Processing
← All platform guides

Install on Shopify

One Liquid snippet in theme.liquid counts every storefront page, and Liquid fills in the page URL and referrer for visitors without JavaScript.

Before you paste anything

Every snippet below shows YOUR-SITE-ID . Replace it with your own site id, which is on the Tracking Code page of the site in your account. If you do not have an account yet, creating one and adding your domain takes about a minute.

Create a free account

Paste the snippet into theme.liquid

  1. In your Shopify admin, go to Online Store, then Themes.
  2. On your current theme, click the three-dot menu, then Edit code.
  3. In the Layout folder, open theme.liquid.
  4. Paste the snippet immediately before the closing </body> tag, then Save.
layout/theme.liquid
<script>
  (function() {
    if (typeof window === 'undefined') return;
    var siteId = {{ 'YOUR-SITE-ID' | json }};
    var trackingDomain = {{ 'www.veritametrics.com' | json }};

    // 1. Initialize the Async Command Queue
    window.verita = window.verita || function() { (window.verita.q = window.verita.q || []).push(arguments) };
    window.verita.l = new Date().getTime();

    // 2. Load the enhanced tracker script
    var script = document.createElement('script');
    script.src = 'https://' + trackingDomain + '/api/tracker.js?siteId=' + siteId;
    script.async = true; script.defer = true;
    script.dataset.siteId = siteId;
    script.dataset.trackingDomain = trackingDomain;
    document.head.appendChild(script);

    // 3. Send the initial pageview using the queue
    window.verita('trackPageView');
  })();
</script>
<noscript>
{%- capture verita_noscript_url -%}https://www.veritametrics.com/api/track-pageview?siteId=YOUR-SITE-ID&url={{ canonical_url | url_encode }}&title={{ page_title | url_encode }}&ref={{ referrer.url | url_encode }}{%- endcapture -%}
  <img src="{{ verita_noscript_url | strip_newlines }}" alt="" width="1" height="1" style="display:none" aria-hidden="true" />
</noscript>
{%- comment -%}
  Usage:
  1. From your Shopify admin, go to Online Store > Themes.
  2. Find your current theme, click Actions > Edit code.
  3. In the Layout directory, click on theme.liquid.
  4. Paste this code before the closing </body> tag.
{%- endcomment -%}

Note: To record order value, call window.verita('trackRevenue', { orderId: '...', amount: 49.99, currency: 'USD' }) from your order-status or thank-you page.

Check that the data is arriving

  1. Open your site in a browser and load any page.
  2. In VeritaMetrics, open the site and click Tracking Code in the sidebar. The status turns active and your visit appears in the recent-pageviews list within a few seconds.

If nothing arrives, open your browser devtools on the Network tab and reload. You should see a request to /api/tracker.js that returns 200, then a request to /api/v1/c when you move or scroll.

A theme change starts you from an empty theme.liquid

The snippet lives in the theme, not in the store. Publishing a different theme, or duplicating one and editing the copy, leaves the new theme with no tracking code. Re-paste it after any theme change, and check the live theme rather than the one you were editing.

Guides for other platforms

The same install, on a different stack.

Explore the documentation

Jump to another guide.