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.


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
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.liquidhtml1<head>2 {{ content_for_header }}3 <script4 defer5 src="https://collect.trimstats.com/t.js"6 data-site="pk_live_your_key"7 data-friction="true"8 ></script>9</head> - 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.jsjs1const 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
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}json1{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
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.
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 name | When to fire | Sample properties |
|---|---|---|
| product_viewed | Shopper lands on a product detail template (or selects a variant swatch). | {"collection":"outerwear","in_stock":true} |
| add_to_cart | Shopper clicks Add to Cart and /cart/add.js succeeds. | {"price_usd":129,"quantity":1} |
| cart_drawer_opened | Shopper opens the slide-out cart drawer to review shipping thresholds. | {"item_count":2} |
| checkout_initiated | Shopper clicks Checkout from the cart drawer or /cart page. | {"currency":"USD"} |
| discount_code_clicked | Shopper interacts with a promo banner or bundle upsell widget. | {"promo":"winter15"} |


Storefront conversion funnel from product landing page to paid order webhook
Illustrative 30-day e-commerce funnel evaluated in ClickHouse across 5 steps
- 1Storefront visit18,500 visitors100.0%
- 2Product page viewed9,420 visitors50.9%-49.1% drop
- 3Added to cart1,680 visitors9.1%-82.2% drop
- 4Checkout initiated790 visitors4.3%-53.0% drop
- 5Verified paid order482 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.
View chart data table
| Label | Shoppers |
|---|---|
| Storefront visit | 18,500 visitors |
| Product page viewed | 9,420 visitors |
| Added to cart | 1,680 visitors |
| Checkout initiated | 790 visitors |
| Verified paid order | 482 visitors |
Shopify analytics FAQ
Implementation details, privacy trade-offs, and event-quota answers.
Will adding TrimStats slow down my Shopify Online Store Speed score?
Does TrimStats require a Shopify cookie banner for European shoppers?
How does TrimStats handle Shopify refunds and multi-currency international orders?
Can TrimStats detect broken mobile Add-to-Cart buttons after a Shopify theme update?
Does TrimStats work with Shopify Hydrogen headless storefronts?
How does TrimStats pricing scale for high-traffic Shopify storefronts?
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.
Related documentation and guides
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.