Routing decision first
Choose the route before changing code:First, identify your Stripe checkout type
AgentRef already instruments hosted Stripe surfaces by itself. If the page contains a real
buy.stripe.com link, <stripe-buy-button>, or <stripe-pricing-table>, you do not need an extra helper script.Hosted Stripe surfaces
If you use Stripe Payment Links, Buy Buttons, or Pricing Tables, install the AgentRef script on the same page as the Stripe element and keep the rest of your flow intact.What AgentRef does automatically
- Appends
client_reference_id=<click token>tobuy.stripe.comlinks - Sets
client-reference-idonstripe-buy-button - Sets
client-reference-idonstripe-pricing-table - Watches for late-rendered Stripe elements with a
MutationObserver
Custom Checkout Sessions
If your CTA goes to your own route, API, server action, or backend first, the script alone is not enough. You need one small bridge: read the AgentRef checkout metadata in the browser and forward it into Stripe when your server creates the session.Step 1: Read AgentRef metadata in the browser
Step 2: Pass the metadata into Stripe on the server
External apps and Chrome extensions
If the buy button does not live on the website where the AgentRef script is installed, do not send the user directly from that external surface to Stripe. This includes Chrome extensions, desktop apps, mobile apps, external dashboards, and any app surface running on a different origin. Do not treat a metadata-only patch inside the external app as complete. The AgentRef cookie usually lives on your website, not insidechrome-extension://... or another external origin.
Instead, route the button to a checkout start page on your website:
window.AgentRef.getCheckoutMetadata(), sends the metadata to your existing checkout backend, and then redirects to the Stripe Checkout URL.
Exact metadata keys
AgentRef expects the metadata object to pass through unchanged:What not to do
- Do not add a second attribution or reporting pipeline for the same Stripe payment.
- Do not overwrite your own
client_reference_idon custom Checkout Sessions unless that field is already reserved for AgentRef. - Do not send external app or Chrome extension buy buttons directly to Stripe when the AgentRef script only runs on your website.
- Do not treat an external app request-schema or Stripe-metadata patch as complete if the flow still starts checkout outside the AgentRef website.
- Do not let an AI coding agent silently reroute checkout without your approval.
- Do not assume Shopify, Webflow Ecommerce, WooCommerce, Wix Stores, or other platform-native checkouts will magically pass this metadata into Stripe. If the platform owns checkout and does not expose Stripe session creation, treat that as a separate integration problem.
Verify the Stripe path
1
Verify the tracking cookies first
Open a real affiliate link and make sure
agentref_cid and agentref_pid are present before checkout starts.2
Trigger one live test checkout
Complete a test purchase through the exact flow you use in production.
3
Inspect Stripe
In Stripe, confirm that the session metadata includes
agentref_cid, agentref_pid, and agentref_source, or that the hosted surface received a client_reference_id.4
Inspect AgentRef
In AgentRef, confirm the conversion appears under Conversions and the tracking diagnostics no longer show a Stripe-event blocker.
Troubleshooting
Related docs
JavaScript Snippet
Core script behavior and
window.AgentRef.How Tracking Works
Full click-to-commission pipeline.
Debug Mode
Inspect hosted Stripe instrumentation and runtime warnings.