Background
⌘K

Nuxt.js Integration

Learn how to integrate Affonso affiliate tracking into your Nuxt.js application.

Silvestro
Written by Silvestro
Updated more than a month ago

Nuxt.js Integration

Nuxt.js provides multiple ways to add tracking scripts that work seamlessly with server-side rendering, static generation, and client-side hydration.

Add tracking script to your Nuxt app

The recommended approach is to create an app.html file in your root directory, which gives you full control over the HTML template that wraps your Nuxt application.

  1. Create an app.html file in your project root directory
  2. Copy the default Nuxt HTML template
  3. Add your Affonso tracking script in the <head> section:
<!DOCTYPE html>
<html {{ HTML_ATTRS }}>
  <head {{ HEAD_ATTRS }}>
    {{ HEAD }}
    <script
      async
      defer
      src="https://affonso.io/js/pixel.min.js"
      data-affonso="YOUR_PUBLIC_PROGRAM_ID"
      data-cookie_duration="YOUR_COOKIE_DURATION"
    ></script>
  </head>
  <body {{ BODY_ATTRS }}>
    {{ APP }}
  </body>
</html>

Find your Program ID →

Alternative: Configure the script via nuxt.config.ts in the app.head.script array or create a client-side plugin.

Testing

  1. Start your development server: npm run dev
  2. Visit localhost:3000?atp=test
  3. Check browser DevTools → Console → type window.affonso_referral
  4. Deploy and verify tracking in your Affonso dashboard

Next Steps

Once installed, you can access affiliate referral data and pass it to your payment provider. Connect your payment provider →

Was this article helpful?

If you still need help, our support team is here for you.

Contact Support
bg

Ready to Scale Your SaaS?

Affonso is the easiest way to launch your own affiliate program. We take care of the technical stuff, so you can focus on growing your business.