Skip to main content
Shopify is the most important builder guide to read carefully because there are two separate questions: can AgentRef capture affiliate visits on the storefront, and can it automatically attribute Shopify-native orders? Those are not the same thing.

Before you start

  • Set the program website in AgentRef to the same root domain as your storefront.
  • Copy the exact script snippet from Settings -> Integration.
  • Decide whether your sales flow uses native Shopify checkout or a supported Stripe flow outside it.

Install the script in your storefront theme

The most reliable Shopify install is still theme-level and global.
  1. In Shopify admin, open Online Store -> Themes.
  2. On your active theme, click ... -> Edit code.
  3. Open layout/theme.liquid.
  4. Paste the AgentRef script before the closing </head> tag.
<script
  defer
  src="https://www.agentref.co/api/tracking/script.js?pid=YOUR_PROGRAM_ID"
></script>
  1. Save and publish the theme change.

What Shopify supports today

FlowStatus with AgentRef
Shopify storefront page with Stripe Payment Links, Buy Buttons, or Pricing Tables embedded directly on the pageSupported directly as long as the AgentRef script loads on that same page.
Custom app or backend that creates Stripe Checkout Sessions outside Shopify’s native checkoutSupported, but you must follow the Stripe guide.
Native Shopify cart, checkout, or Shop Pay flowNot an automatic AgentRef attribution surface today.
This is the core product constraint: AgentRef does not automatically read native Shopify order events and turn them into attributed conversions just because the storefront has the tracking script installed.

What that means in practice

  • If Shopify is only your marketing layer and the actual paid checkout happens in your own Stripe flow, AgentRef can work well.
  • If you rely on Shopify’s own checkout, use a deliberate server-side reporting strategy or a different supported checkout surface.
  • Do not promise affiliates automatic Shopify-native attribution unless you have built and tested that bridge intentionally.
  • If your storefront is www.example.com and your app or billing area is app.example.com, install AgentRef on both.
  • If Shopify uses a different root domain than the page that starts checkout, cookies will not carry across automatically.
  • If you use a consent banner, call window.AgentRef.setConsent('granted') after opt-in.

Verify the installation

1

Verify storefront tracking

Open a real affiliate link to the storefront and confirm agentref_cid and agentref_pid appear.
2

Confirm the published theme contains the script

View page source or DevTools Network on the live storefront.
3

Validate the actual checkout path

If you use native Shopify checkout, stop here and document that this is not an automatic AgentRef conversion path. If you use Stripe outside Shopify checkout, continue with the Stripe guide.

Troubleshooting

  • The script is in the theme editor but not live: the edited theme may not be the active theme.
  • Storefront clicks show up but conversions do not: this is expected for native Shopify checkout unless you built a separate attribution bridge.
  • Cookies disappear between storefront and app: install AgentRef on both subdomains and keep everything under one root domain where possible.

Stripe Checkout

Use this if your paid flow leaves native Shopify checkout and creates Stripe sessions directly.

Server-Side Tracking

Fallback when the platform-controlled checkout path cannot pass AgentRef through automatically.

How Tracking Works

Understand what the script does and what it does not do.