Background
⌘K

Vue.js Integration

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

Silvestro
Written by Silvestro
Updated more than a month ago

Vue.js Integration

Add Affonso tracking to your Vue.js application using one of these proven methods that work with Vue CLI, Vite, or any Vue 3+ setup.

Method 1: Main Entry File (Recommended)

Add the tracking script to your main file, typically main.js:

import { createApp } from 'vue';
import App from './App.vue';

// Add Affonso tracking script
const script = document.createElement('script');
script.async = true;
script.defer = true;
script.setAttribute('data-affonso', 'YOUR_PUBLIC_PROGRAM_ID');
script.setAttribute('data-cookie_duration', '30');
script.src = 'https://affonso.io/js/pixel.min.js';
document.head.appendChild(script);

createApp(App).mount('#app');

Method 2: Root Component

Add the script in your root App.vue component:

<template>
  <div id="app">
    <!-- Your app content -->
  </div>
</template>

<script>
export default {
  name: 'App',
  mounted() {
    const script = document.createElement('script');
    script.async = true;
    script.defer = true;
    script.setAttribute('data-affonso', 'YOUR_PUBLIC_PROGRAM_ID');
    script.setAttribute('data-cookie_duration', '30');
    script.src = 'https://affonso.io/js/pixel.min.js';
    document.head.appendChild(script);
  },
};
</script>

Method 3: Index HTML

Add the script directly to your index.html file:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Your Vue App</title>

    <script
      async
      defer
      src="https://affonso.io/js/pixel.min.js"
      data-affonso="YOUR_PUBLIC_PROGRAM_ID"
      data-cookie_duration="30"
    ></script>
  </head>
  <body>
    <div id="app"></div>
  </body>
</html>

Find your Program ID →

Next Steps

Once installed, you can access affiliate referral data and pass it to your payment provider. Learn how to integrate with your payment provider →

Testing

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

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.