Skip to main content

Documentation Index

Fetch the complete documentation index at: https://agentref.co/docs/llms.txt

Use this file to discover all available pages before exploring further.

Svelte and SvelteKit both work well with AgentRef as long as the script is installed in the global shell instead of a page-specific component.

Before you start

  • Set the program website in AgentRef to the same root domain your app serves.
  • Copy the exact script snippet from Settings -> Integration.
  • If your app and checkout start on different subdomains, install AgentRef on both.
Install the script in src/app.html so it is available across all routes.
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <script
      defer
      src="https://www.agentref.co/api/tracking/script.js?pid=YOUR_PROGRAM_ID"
    ></script>
    %sveltekit.head%
  </head>
  <body>
    <div style="display: contents">%sveltekit.body%</div>
  </body>
</html>

Checkout compatibility in Svelte

Checkout patternRecommendation
Hosted Stripe surfaces on Svelte pagesSupported directly.
Custom Checkout Sessions created by your serverSupported with the Stripe guide.
Checkout on a different root domainNot automatic because AgentRef uses first-party cookies.

Svelte-specific notes

  • Do not reinstall AgentRef in onMount() for every route. One shell-level install is enough.
  • Hosted Stripe elements rendered after hydration are still observed automatically.
  • If you gate cookies behind consent, call window.AgentRef.setConsent('granted') after opt-in.

Verify the installation

  1. Open the live app through a real affiliate link.
  2. Confirm agentref_cid and agentref_pid in browser cookies.
  3. Add ?agentref_debug=1 and inspect the console.
  4. Complete one supported checkout flow and verify the conversion in AgentRef.

Troubleshooting

  • window.AgentRef is undefined: the script was not installed in the global shell.
  • Clicks appear but conversions do not: your custom checkout path still needs the Stripe metadata bridge.
  • Cookies fail across domains: move the journey onto one root or handle the handoff server-side.

Stripe Checkout

Metadata bridge for custom Stripe sessions.

Consent and GDPR

Coordinate AgentRef with your consent banner.

Debug Mode

Runtime inspection and troubleshooting.