REVENUE ATTRIBUTION
Shopify
Connect your Shopify store so Attrifast tracks your storefront automatically and attributes every paid order to the traffic source that drove it.
Connecting Shopify takes about 5 minutes and requires no coding. Once connected, Attrifast automatically:
- Tracks your storefront — the tracker is injected into your Online Store theme for you. No theme editing, no snippet to paste.
- Tracks funnel events —
add_to_cartandinitiate_checkoutfire automatically, ready to use as conversion goals. - Attributes order revenue — every paid order is linked back to the visitor who placed it and the marketing channel that brought them, including AI engines like ChatGPT and Perplexity.
If you previously pasted the Attrifast <script> snippet into your theme manually, remove it before connecting. The Shopify integration installs the tracker automatically — running both causes duplicate pageviews.
Before you start
You'll need:
- An Attrifast website already added to your account, and a Pro subscription (Shopify connect is a Pro feature — there's a 7-day free trial).
- A Shopify store on an Online Store (theme-based) storefront. Headless and Hydrogen storefronts are not supported yet.
- Your store's
*.myshopify.comdomain (find it under Settings → Domains in Shopify admin). The connect form intentionally rejects custom domains.
Step 1 — Create a Shopify app (2 minutes)
Attrifast connects through a private app that you create in your own Shopify organization — you stay in control and can revoke access at any time by uninstalling the app. Attrifast stores the app's credentials to mint short-lived API tokens and verify webhook signatures.
Create the app
Go to the Shopify Dev Dashboard and sign in (create a free account if you don't have one). Click Apps → Create app, name it anything you like — for example Attrifast — and click Create.
Enable the two required scopes
Under Configuration → Admin API access scopes, enable exactly two scopes:
read_orders— lets Attrifast receive paid-order webhookswrite_script_tags— lets Attrifast inject the tracker into your storefront
If your app's configuration shows a Protected customer data access section (order data counts as protected), request access to order data there — Shopify won't deliver order webhooks without it.
Release a version
Scroll down and click Release. Scopes only take effect once a version is released — an unreleased app will fail to connect later with a "missing required scopes" error.
Step 2 — Install the app on your store (1 minute)
Install from the Dev Dashboard
Back on your app's Home in the Dev Dashboard, click Install app and pick the store you want to connect.
Confirm in Shopify admin
You'll be redirected to your Shopify admin — click Install.
Step 3 — Connect in Attrifast (1 minute)
Copy the credentials
From your app's Settings → Credentials page in the Dev Dashboard, copy the Client ID and the Client secret (starts with shpss_).
Fill in the connect form
The connect form lives in two places — use whichever you're closer to:
- Onboarding → step 2 "Install script" → Shopify tab
- Dashboard → Settings → Install script → Shopify tab
| Field | What to paste |
|---|---|
| Shopify store domain | your-store.myshopify.com |
| Client ID | The Client ID from your app's credentials page |
| Client secret | The shpss_… secret from the same page |
Click Connect Shopify
On success you'll see: "Connected to your-store.myshopify.com. Attrifast is now tracking analytics and attributing revenue from orders." That's it — your store is connected. 🎉
What happens when you connect
Behind the scenes, Attrifast:
- Exchanges your app credentials for a short-lived Admin API token (auto-refreshed — you never handle raw tokens).
- Registers a ScriptTag so the tracker loads on every storefront page.
- Registers an
orders/paidwebhook — the revenue source. - Adds your
myshopify.comand primary domains to the website's allowed hostnames so storefront events are accepted.
Reconnecting first removes the previously registered ScriptTag and webhook, so you won't end up with duplicate tracking.
Automatic funnel events
On a connected storefront the tracker fires two events with zero configuration:
add_to_cart— when a product is successfully added to the cart. Works with AJAX carts (fetch and XHR) and with older themes that do a full-page form submit. Failed adds (e.g. sold out) don't count.initiate_checkout— when the visitor clicks a checkout button or link, before they leave for the checkout.
Both show up in your dashboard's events list like any custom event and can be turned into goals to measure cart and checkout conversion by channel. Each fired event counts as one event against your monthly plan quota — high-traffic stores should factor that in.
Buy Now / dynamic checkout buttons skip the cart entirely, so they produce no add_to_cart (the same reason their orders fall back to UTM/referrer attribution — see Limitations).
Verify your setup
Check the tracker loads
Open your storefront in a fresh browser tab. In DevTools → Network you should see af.js?id=<your-tracking-id> load, followed by a request to /api/collect. The visit usually appears in your Attrifast dashboard within a minute.
Check the cart attribute
Add any product to the cart, then open https://your-store.myshopify.com/cart.js in the same browser. The JSON should contain "attributes": { "_rp_vid": "…" }. The add should also appear as an add_to_cart event in your dashboard.
Place a paid test order
Complete a checkout using a test gateway (Shopify's Bogus Gateway or Shopify Payments test mode) — the webhook only fires when an order is paid, so an unpaid draft won't show up. The order usually appears in your dashboard's revenue within a minute, attributed to a channel.
Test-gateway orders are currently recorded as real revenue — they are not filtered out. Do your test order before sharing dashboards, or keep it small and easy to recognize.
How orders are attributed
On your storefront the tracker stamps its visitor ID into the Shopify cart (as the cart attribute _rp_vid), and re-asserts it after cart changes so theme updates can't drop it. When the orders/paid webhook arrives, Attrifast links the order to that visitor and attributes it using a 7-day last non-direct click model. Orders that arrive without a visitor link fall back, in order, to the order's landing-page UTMs, then its referrer, then Direct.
See the revenue attribution guide for the full model, including how AI-influenced revenue works.
Limitations
- Only paid orders are counted, and revenue is only ever added: refunds, cancellations, and order edits are not reflected yet.
- Buy Now / dynamic checkout buttons skip the cart, so those orders can't carry the visitor link — they fall back to UTM/referrer/Direct attribution, and no
add_to_cartevent fires for them. - One Shopify store connects to exactly one Attrifast website (and vice versa).
- The injected tracker isn't guaranteed to run on checkout or thank-you pages. Revenue comes exclusively from the webhook, so this doesn't affect attribution.
- The ScriptTag and webhook registered via the API are not visible in the Shopify admin UI — verify via the storefront checks above instead.
Troubleshooting
| Error / symptom | Cause and fix |
|---|---|
| "Shopify rejected these credentials…" | The app isn't installed on this store, or the Client ID/secret are wrong. Confirm the app is installed on this exact store and re-copy both values from Settings → Credentials. |
| "The Shopify app is missing required scopes…" | Add read_orders and write_script_tags under Configuration → Admin API access scopes, release a new version, then retry. Scopes only take effect once released. |
| "Could not reach Shopify. Check the store domain…" | Usually a typo'd or custom domain. Use the *.myshopify.com address from Settings → Domains. |
| "This Shopify store is already connected to another site." | The store is attached to a different Attrifast website. Disconnect it there first, then reconnect. |
| 403 "A subscription is required to access this feature." | Shopify connect is a Pro feature — start the 7-day free trial, then retry. |
| Duplicate pageviews after connecting | The tracker snippet is still pasted manually in your theme. Remove the manual <script> tag — the integration injects the tracker automatically. |
| Connected, but no pageviews | The storefront domain isn't in the website's allowed hostnames (this can happen if you changed your primary domain after connecting). Reconnect Shopify to re-sync the hostname list. |
| Orders show as Direct / UTM channel with no visitor | Expected for cart-bypassing checkouts (Buy Now buttons). For normal flows, verify the cart attribute check above passes. |
| Orders never appear; API logs show "Invalid webhook signature" | Your app's Client secret was rotated in Shopify after connecting, so webhook signatures no longer verify. Reconnect with the current secret. |