Vue 3
Add Produl to a Vue 3 app. Choose between the composable for scoped setup or the plugin for global registration.
Install
- 1
Add the package
bashnpm install produl-tracker - 2
Choose an integration method
The Vue adapter exports both a
useAnalyticscomposable and ananalyticsPlugin. Pick the one that fits your app structure.
Option A: Composable
Call useAnalytics(props) once in your root component — typically App.vue. This is the most lightweight option and works well when you want to co-locate setup with your root template.
src/App.vuevue
<script setup>
import { useAnalytics } from 'produl-tracker/vue'
useAnalytics({ siteId: 'YOUR_SITE_ID' })
</script>
<template>
<RouterView />
</template>Option B: Plugin
Register analyticsPlugin globally via app.use() in main.ts. The plugin accepts the same props as the composable. Use this approach when you want Produl initialized alongside other plugins in one place.
src/main.tsts
import { createApp } from 'vue'
import { analyticsPlugin } from 'produl-tracker/vue'
import App from './App.vue'
const app = createApp(App)
app.use(analyticsPlugin, { siteId: 'YOUR_SITE_ID' })
app.mount('#app')Both options initialize the same tracker. You only need one — using both will result in duplicate pageviews.
Configuration
| Prop | Type | Default | Description |
|---|---|---|---|
siteId | string | — | Required. Your site ID from the dashboard. |
serverUrl | string | hosted instance | Override the tracker server URL. |
disableAutoTrack | boolean | false | Disable automatic pageview tracking on route changes. |
endpoint | string | /api/collect | Base URL that pageview and event data is sent to. |
debug | boolean | false | Show a debug overlay listing every tracked event. |
Vite env var
Set
VITE_MULTIANALYTICS_URL in your .env file to override the server URL without passing a prop.