Install

Add analytics and revenue attribution to Shopify

A Shopify install is a two-line edit to theme.liquid. The part most guides skip is the checkout: Shopify controls those pages, so a theme script can't follow a customer through them — and pretending otherwise is how store owners end up with attribution they can't trust.

Start a 14-day trialLast reviewed August 2026
  1. Add the snippet to theme.liquid

    Online Store → Themes → Edit code → layout/theme.liquid. Paste the tag just before </head>. It now runs on every storefront page: home, collections, products, cart.

    layout/theme.liquid
    <script defer src="https://revtrail.pyln.dev/track.js" data-site="SITE_KEY"></script>
  2. Track add-to-cart and begin-checkout as goals

    These are the storefront events you fully control, and they're the leading indicators worth attributing by channel. Fire them from your theme's cart JavaScript.

    your theme's cart script
    window.revtrail && window.revtrail('add_to_cart');
    // and on the checkout button:
    window.revtrail && window.revtrail('begin_checkout');
  3. Get order revenue from Stripe, not from the browser

    Shopify's checkout pages are outside your theme, so a storefront script can't observe the completed order. If your payments settle through Stripe, point that Stripe webhook at Revtrail and orders arrive verified and deduplicated. Where they settle through Shopify Payments, treat begin_checkout as your storefront conversion and reconcile revenue against Shopify's own reports.

  4. Confirm it's receiving

    Open your site in a normal browser tab, then check Realtime in the Revtrail dashboard — your own visit should appear within a few seconds. If nothing arrives, the usual causes are a mistyped site key, an ad blocker on your own browser, or a Content-Security-Policy that blocks the script origin.

What a theme script can and can't see

It sees every storefront page and every event you fire from your theme. It does not see Shopify's hosted checkout, and it cannot fire on the order-status page unless you're on a plan that allows checkout scripts. Any tool that claims full checkout visibility from a theme snippet on a standard plan is describing something Shopify doesn't allow.

Where this beats Shopify's built-in reports

Shopify Analytics is good at orders, products, and repeat purchase rate. It's weaker at the top of the funnel — which post, campaign, or newsletter brought the person who eventually bought, and what visitors from each channel are worth over time. That's the gap Revtrail fills, and it's why the two coexist rather than compete.

One store, many channels

UTM parameters on every campaign link are what make this work. Tag your ads, your newsletter, and your affiliate links consistently and the source report becomes a revenue report. Untagged links collapse into 'direct' and no analytics tool can recover them after the fact.

Questions people actually ask

Can Revtrail see Shopify checkout completions?
Not from the theme script — Shopify owns those pages. Verified order revenue comes through the Stripe webhook where your payments settle through Stripe.
Will this conflict with the Shopify apps I already have?
No. It's an independent script tag with its own beacon, and it doesn't touch the cart or checkout objects.
Do I need a cookie banner for this?
Not for Revtrail. The default identity is a daily rotating hash — no cookies, no persistent identifier, nothing stored on the device. If you run ad pixels or other analytics that do use cookies, their obligations are unchanged.
Will this slow my site down?
The script is deferred, so it never blocks rendering, and it's about 3KB over the wire gzipped. It fires one beacon per pageview.

Install guides

All install guides