Enabling debug mode
You can enable debug mode in two ways: Option 1: URL parameter (temporary, no code change) Append?agentref_debug=1 to any page URL on your site:
[AgentRef] log entry immediately after the script initializes.
Option 2: Script attribute (always-on)
Add data-debug="true" to your script tag to log on every page load:
What debug mode shows
The console output is the return value ofwindow.AgentRef.getDebugInfo(). Here is an example:
Field reference
| Field | What it tells you |
|---|---|
params.referralCode | The affiliate code detected in the URL (null if none) |
params.clickToken | Pre-existing click token from a redirect URL (null for direct clicks) |
cookies.clickToken | The agentref_cid cookie value – this is what goes into Stripe metadata |
cookies.programId | The agentref_pid cookie – confirms which program the current attribution belongs to |
trackingScope.mode | "root" = cookies scoped to root domain; "host" = scoped to exact hostname only |
warnings | Array of warning codes if anything went wrong (empty = clean init) |
Warning codes
| Warning | Meaning |
|---|---|
consent_pending | Consent is required but not yet granted – tracking was skipped |
host_outside_website_domain | The current hostname doesn’t match your program’s website domain |
cleanup_failed | URL parameter cleanup via history.replaceState failed |
stripe_payment_link_rewrite_failed | Could not append client_reference_id to a Stripe Payment Link |
direct_click_failed | The click recording request to AgentRef failed |
tracking_verify_failed | The verification request failed |
Calling getDebugInfo() manually
You can call it any time from the browser console:
AgentRef.refresh() call – any time you want to see the current state without reloading the page.
Troubleshooting checklist
Script is not loading
Script is not loading
- Open the Network tab in DevTools and filter for
script.js. Check the response status. - A
404means your?pid=value is invalid or the program does not exist. Verify the program ID in your AgentRef dashboard. - A
400response with// Missing program IDmeans the?pid=query string is missing entirely. - Check for Content Security Policy (CSP) headers blocking
https://www.agentref.co. Add it to yourscript-srcandconnect-srcdirectives.
Cookies are not being set
Cookies are not being set
Clicks are tracked but conversions are not created
Clicks are tracked but conversions are not created
- Verify that
getCheckoutMetadata()returns a non-empty object before checkout. Call it from the console:window.AgentRef.getCheckoutMetadata(). - Confirm the metadata is being passed to Stripe. Check the session object in your Stripe dashboard – look for
agentref_cidin the metadata fields. - For Payment Links, confirm the link on your page has
data-agentref-instrumented="true"after the script loads – this attribute is set by the script when it successfully instruments a link. - Check that your Stripe Connect integration is active in AgentRef. If the webhook is not receiving events, no conversions will be created.
Attribution is set but the wrong affiliate gets credit
Attribution is set but the wrong affiliate gets credit
AgentRef uses last-click attribution. If a visitor clicked multiple affiliate links before purchasing, the most recent click wins.Coupon codes take priority over click tokens – if the customer uses a coupon linked to a different affiliate, that affiliate gets credit regardless of which link the visitor clicked.Check the conversion detail in your dashboard to see which attribution method was used (click token vs. coupon code).