Shopify IntegrationShopify Liquid Themes & Storefronts

Fast 1.96 KB Shopify analytics that catches broken mobile buttons and attributes orders.

Add one deferred script to layout/theme.liquid to measure storefront traffic, spot rage clicks on mobile Add-to-Cart buttons, and reconcile paid orders via signed webhooks.

Istiak Rayhan
Istiak RayhanCo-Founder & Product Lead, DotCamp & TrimStats
Tested against Shopify & live TrimStats APIs
Seeded demo workspace
TrimStats Revenue Attribution dashboard displaying net revenue, orders, AOV, revenue per visitor, and top converting referrers and landing pagesTrimStats Revenue Attribution dashboard displaying net revenue, orders, AOV, revenue per visitor, and top converting referrers and landing pages
Compare Net Revenue, Average Order Value (AOV), and Revenue per Visitor (RPV) across organic search, social campaigns, and product landing pages.
Direct answer

How do you install TrimStats on a Shopify storefront and attribute order revenue?

Install TrimStats on Shopify by pasting the 1.96 KB gzipped deferred script tag inside <head> in Online Store -> Themes -> Edit code -> layout/theme.liquid. Storefront traffic, 90% scroll reach, and opt-in rage or dead clicks track immediately with zero cookies, and server-side Shopify orders/paid webhooks attribute net revenue via TrimStats Custom HMAC endpoints.

Step-by-step setup for Shopify

Copy-paste implementation verified against the live TrimStats tracker and collector APIs.

  1. 1

    Paste the deferred TrimStats script inside layout/theme.liquid

    In Shopify Admin, open Online Store -> Themes -> Edit code -> layout/theme.liquid and add the tag just before </head>. Include data-friction="true" to surface mobile rage clicks and dead clicks on product and cart pages.

    layout/theme.liquidhtml
    1<head>
    2 {{ content_for_header }}
    3 <script
    4 defer
    5 src="https://collect.trimstats.com/t.js"
    6 data-site="pk_live_your_key"
    7 data-friction="true"
    8 ></script>
    9</head>
  2. 2

    Attach the attribution snapshot to Shopify cart attributes

    Before a shopper proceeds to checkout, save window.trimstats?.attribution?.() into Shopify cart attributes (/cart/update.js) so the snapshot travels with the order payload into Shopify webhooks.

    assets/trimstats-cart.jsjs
    1const attr = window.trimstats?.attribution?.();
    2if (attr) {
    3 fetch('/cart/update.js', {
    4 method: 'POST',
    5 headers: { 'content-type': 'application/json' },
    6 body: JSON.stringify({ attributes: { trimstats: JSON.stringify(attr) } }),
    7 });
    8}
  3. 3

    Forward Shopify orders/paid webhooks to TrimStats Custom HMAC

    From your lightweight webhook relay or Shopify app backend, sign the normalized order JSON (tx_id, amount_cents, currency, tx_type, and note_attributes.trimstats) with x-trimstats-signature and POST to /v1/webhooks/custom/{siteId}.

    POST /v1/webhooks/custom/{siteId}json
    1{
    2 "tx_id": "shopify_order_849201",
    3 "amount_cents": 12900,
    4 "currency": "USD",
    5 "tx_type": "one_time",
    6 "attribution": {
    7 "ref": "https://google.com/",
    8 "lp": "/products/merino-hoodie",
    9 "utm_source": "newsletter",
    10 "utm_campaign": "winter_drop"
    11 }
    12}
  4. 4

    Set up Add-to-Cart funnels and anomaly alerts

    Create a multi-step funnel from product pageview -> add_to_cart -> checkout_initiated -> paid order, and configure 6-hour anomaly alerts to catch sudden theme or checkout regressions.

Recommended taxonomy

High-signal custom events to track for Shopify

Fire any event with window.trimstats?.('event', name, props) and attach it to conversion goals or multi-step ClickHouse funnels.

Event nameWhen to fireSample properties
product_viewedShopper lands on a product detail template (or selects a variant swatch).{"collection":"outerwear","in_stock":true}
add_to_cartShopper clicks Add to Cart and /cart/add.js succeeds.{"price_usd":129,"quantity":1}
cart_drawer_openedShopper opens the slide-out cart drawer to review shipping thresholds.{"item_count":2}
checkout_initiatedShopper clicks Checkout from the cart drawer or /cart page.{"currency":"USD"}
discount_code_clickedShopper interacts with a promo banner or bundle upsell widget.{"promo":"winter15"}
Seeded demo workspace
TrimStats UI Friction report listing rage clicks, dead clicks, and top friction pages to catch broken mobile storefront buttonsTrimStats UI Friction report listing rage clicks, dead clicks, and top friction pages to catch broken mobile storefront buttons
Pinpoint unresponsive mobile variant selectors, overlapped Add-to-Cart buttons, and deceptive static badges without loading a heavy replay app.

Storefront conversion funnel from product landing page to paid order webhook

Illustrative 30-day e-commerce funnel evaluated in ClickHouse across 5 steps

visitors
  1. 1Storefront visit
    18,500 visitors100.0%
  2. 2Product page viewed
    9,420 visitors50.9%-49.1% drop
  3. 3Added to cart
    1,680 visitors9.1%-82.2% drop
  4. 4Checkout initiated
    790 visitors4.3%-53.0% drop
  5. 5Verified paid order
    482 visitors2.6%-39.0% drop

Evaluating checkout_initiated (790) against server-verified paid orders (482) highlights exact checkout conversion without ad-blocker pixel loss.

Methodology: Illustrative 5-step storefront funnel showing TrimStats ClickHouse funnel calculation joined with Custom HMAC order webhooks.

Source: TrimStats e-commerce funnel model
View chart data table
LabelShoppers
Storefront visit18,500 visitors
Product page viewed9,420 visitors
Added to cart1,680 visitors
Checkout initiated790 visitors
Verified paid order482 visitors

Shopify analytics FAQ

Implementation details, privacy trade-offs, and event-quota answers.

Will adding TrimStats slow down my Shopify Online Store Speed score?
No. TrimStats loads with the defer attribute at 1,964 bytes gzipped (1,732 bytes Brotli) with zero third-party dependencies and sends beacons via text/plain sendBeacon so Liquid rendering and Shopify LCP stay fast.
Does TrimStats require a Shopify cookie banner for European shoppers?
Not in default cookie-less mode. TrimStats stores zero cookies or localStorage on shopper devices and hashes visits transiently on EU servers in Germany with a 24-hour rotating salt. Remember to check other Shopify marketing apps that may set their own cookies.
How does TrimStats handle Shopify refunds and multi-currency international orders?
Your Custom HMAC webhook can send negative amount_cents with tx_type: "refund" on Shopify refunds/create webhooks, and TrimStats automatically normalizes 13 currencies (including USD, EUR, GBP, CAD, AUD, and JPY) into USD.
Can TrimStats detect broken mobile Add-to-Cart buttons after a Shopify theme update?
Yes. With data-friction="true" enabled, TrimStats flags rage clicks (3 clicks inside 1,000 ms within 30 px) and dead clicks (zero DOM change for 500 ms), returning the exact offending CSS selector and alerting you automatically on friction_spike surges.
Does TrimStats work with Shopify Hydrogen headless storefronts?
Yes. Because t.js automatically intercepts history.pushState and popstate transitions, it tracks client-side route navigations in Shopify Hydrogen and Remix storefronts without extra router listeners.
How does TrimStats pricing scale for high-traffic Shopify storefronts?
TrimStats charges flat event-based tiers starting at $17 Starter (100k events), $44 Growth (1M events), and $134 Scale (5M events) with a 20% soft grace buffer and pre-billing bot filtering so Black Friday spikes never silently drop orders.
Istiak Rayhan
Integration guide verified by
Istiak Rayhan (Co-Founder & Product Lead, DotCamp & TrimStats)

Co-founder and Product Manager at DotCamp LLC and co-creator of TrimStats. Publisher, SEO practitioner, and WordPress product leader building creator tools since 2012.

  • • Co-founder & Product Manager at DotCamp LLC (est. 2019), guiding product strategy for Ultimate Blocks, WP Table Builder, OptimizeCamp, and TrimStats
  • • Full-time publisher and digital marketer since 2012; founder of RoadToBlogging.com and WPLeaders.com
  • • WordPress.org Plugin Developer, Support Contributor, and WordCamp Sylhet 2023 speaker on building WordPress products

Verification standard: Code snippets, custom event payloads, and webhook contracts for Shopify are verified against the live TrimStats tracker (1.96 KB gzipped) and collector schema as of 2026-11-30.

Instrument Shopify in under 60 seconds

Start on Starter ($17/month for 100,000 monthly events), with cookie-less privacy defaults and full access to revenue webhooks, funnels, cohorts, and UI friction.

Verified against live TrimStats APIs and tracker bundle.