Vue ​
Use the useTracking composable in any Vue 3 app.
The composable ​
ts
import { useTracking } from 'attribution-kit/vue'
const { tracking, getPayload } = useTracking({ ttlDays: 30 })
// `tracking` is reactive — read the first/last source and touch history
console.log(tracking.value)Attaching attribution to requests ​
Use getPayload() to add the tracking data to outgoing requests — for example in an axios interceptor:
ts
axios.interceptors.request.use((config) => {
if (['post', 'put', 'patch'].includes(config.method ?? '')) {
config.data = { ...config.data, ...getPayload() }
}
return config
})Registering the plugin (optional) ​
Register the plugin if you'd like to share options across the whole app:
ts
import { createApp } from 'vue'
import Attribution from 'attribution-kit/vue'
import App from './App.vue'
createApp(App)
.use(Attribution, { ttlDays: 30 })
.mount('#app')See all available options in the API reference.