First, identify your Stripe checkout type
| Checkout type | What AgentRef needs |
|---|---|
| Stripe Payment Links | Script on the page with the link. No backend bridge required. |
| Stripe Buy Buttons | Script on the page with the button. No backend bridge required. |
| Stripe Pricing Tables | Script on the page with the pricing table. No backend bridge required. |
| Server-created Stripe Checkout Session | Script plus a metadata bridge from browser to server to Stripe. |
| Direct PaymentIntents / custom Stripe flow | Script plus a metadata bridge into your payment intent or checkout backend. |
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
Exact metadata keys
AgentRef expects the metadata object to pass through unchanged:What not to do
- Do not add a second manual conversion-reporting call 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 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
Verify the tracking cookies first
Open a real affiliate link and make sure
agentref_cid and agentref_pid are present before checkout starts.Trigger one live test checkout
Complete a test purchase through the exact flow you use in production.
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.Troubleshooting
| Problem | What to check |
|---|---|
| Hosted Stripe link was clicked but no conversion appeared | Make sure the AgentRef script was loaded on the same page as the link or Stripe element. |
| Custom session created but conversion missing | Check that your backend wrote the AgentRef keys into metadata and subscription_data.metadata or payment_intent_data.metadata. |
| Pricing table or buy button renders late | AgentRef already watches the DOM for late Stripe elements. Usually this means the script was not installed at all or loaded on the wrong page. |
| Tracking health still shows a Stripe blocker | You may have clicks but no completed Stripe event yet. Finish one supported checkout flow end-to-end. |
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.