Before starting: Get your API key from the Settings page
Step 1 — Install the SDK
Step 2 — Initialize in src/main.js (One-time setup)
Open src/main.js. This is the only file you need to change for the core setup. Add the init() call before you mount the app.
src/main.js
.env:
That’s the core setup! You can now track events from anywhere in your app.
What the SDK handles automatically
Step 3 — Identify users and reset on logout
Vue doesn’t use hooks, so you callidentify() and reset() directly. The best place is your Pinia store or auth composable:
- Pinia Store (Recommended)
- Inside a component
src/stores/auth.js
Step 4 — Track Custom Events
For specific actions (button clicks, purchases, etc.), importtrack() in any component:
- On page load with extra data
- After an API call
Step 5 — Verify it’s working
- Run:
npm run dev - Open your browser, Press F12 and go to Console
- You should see:
- Navigate between pages in your app
- Go to your Analytiq Dashboard → Events —
page_viewevents appear within 10 seconds.