GuidesWeb

Vue analytics, cookieless event tracking hosted in the EU

Cookieless analytics for Vue 3, built on the OpenPanel web SDK.

Privytics tracks page views and custom events in Vue applications using the OpenPanel web SDK, `@openpanel/web`. There is no separate Vue package and none is needed: you create a single OpenPanel instance in one file, import it wherever you need it, and automatic screen view tracking follows Vue Router without extra wiring. Setup is roughly ten lines plus one import in your entry point.

Why Vue teams use Privytics

No Vue wrapper to keep in sync

The SDK is plain framework-agnostic JavaScript, so the same instance works in `<script setup>`, the Options API, composables, Pinia stores and router guards. Nothing binds to a specific Vue minor release, and the upstream Vue guide confirms it works in Vue 2 projects as well as Vue 3.

Vue Router navigations are counted as screen views

A Vue SPA never reloads the document, so naive page-view tracking records one visit and stops. With `trackScreenViews: true` the SDK listens for URL changes, so every client-side route transition is recorded. When you need route names or params on the event, an `afterEach` guard gives you full control instead.

Declarative click tracking straight from templates

With `trackAttributes: true` the SDK attaches one global click listener. Put `data-track="event_name"` on a `<button>` or an `<a>` in your template and clicking it fires that event; any other `data-*` attribute on the same element is sent as a property with a camelCased name, so `data-plan="pro"` arrives as `plan: 'pro'`. It matches only buttons and links, so wrap other clickable elements in a button. Simple CTA tracking stays in the markup instead of threading handler props through components.

Cookieless, so nothing is written to the visitor's device

Vue apps often ship as a public marketing SPA where a consent wall costs you data. Privytics sets no cookies and stores nothing on the device; the anonymous visitor id resets every day. Event data is stored in EU data centres in Germany.

Set it up

About five minutes, on the free plan, without a credit card.

  1. Install the SDK

    Vue uses the OpenPanel web SDK directly. There is no @openpanel/vue package.

    npm install @openpanel/web
  2. Create a shared instance

    Create one OpenPanel instance for the whole app. Setting apiUrl is required, because the SDK otherwise defaults to OpenPanel's own hosted endpoint.

    // src/lib/op.ts
    import { OpenPanel } from '@openpanel/web';
    
    export const op = new OpenPanel({
      clientId: 'YOUR_CLIENT_ID',
      apiUrl: 'https://api.privytics.com',
      trackScreenViews: true,
      trackOutgoingLinks: true,
      trackAttributes: true,
    });
  3. Initialise it on app load

    Import the module in your entry point so the instance is created when the app boots. That alone starts automatic screen view tracking.

    // src/main.ts
    import { createApp } from 'vue';
    import App from './App.vue';
    import router from './router';
    import './lib/op'; // initialise Privytics
    
    const app = createApp(App);
    app.use(router);
    app.mount('#app');
  4. Track an event in a component

    Import the instance and call track with an event name and an optional properties object. To link events to a logged-in user, call op.identify with a single object that has a profileId, for example op.identify({ profileId: user.id }), when you have a lawful basis for it.

    <template>
      <button type="button" @click="handleClick">Sign up</button>
    </template>
    
    <script setup lang="ts">
    import { op } from '../lib/op';
    
    function handleClick() {
      op.track('button_clicked', {
        button_name: 'signup',
        button_location: 'hero',
      });
    }
    </script>
  5. Optional: track routes with a Vue Router guard

    Use this only if you want route names or params on the event. Set trackScreenViews to false in step 2 when you do, otherwise every navigation is counted twice.

    // src/router/index.ts
    import { createRouter, createWebHistory } from 'vue-router';
    import { op } from '../lib/op';
    import routes from './routes';
    
    const router = createRouter({
      history: createWebHistory(),
      routes,
    });
    
    router.afterEach((to) => {
      op.track('screen_view', {
        path: to.path,
        name: String(to.name),
      });
    });
    
    export default router;

Privytics runs the open-source OpenPanel engine, so the upstream Vue SDK reference applies here too. Point apiUrl at Privytics and the data lands in your Privytics project.

Questions

Is there an @openpanel/vue package?

No. The name is unpublished on npm and the upstream docs state that Vue SPAs should use @openpanel/web directly. You create one OpenPanel instance and import it across your components, so a Vue-specific wrapper is not needed.

Does it track page views with Vue Router?

Yes. With trackScreenViews set to true the SDK records a screen view whenever the URL changes, which covers Vue Router's client-side navigation. If you want route names or params attached, use an afterEach guard instead and turn trackScreenViews off to avoid double counting.

Does it work with Vue 2 or the Options API?

Yes. The SDK is framework-agnostic JavaScript with no Vue bindings, so the same imported instance works in Vue 2, in Options API methods and in <script setup>. The upstream Vue guide confirms Vue 2 support.

How does data-track work in a template?

Set trackAttributes to true, then put data-track="event_name" on a button or a link. Clicking it sends that event, and every other data-* attribute on the element is sent as a property with a camelCased name. It only matches button and anchor elements, so wrap anything else you want to track in a button.

Does Privytics set cookies in my Vue app?

No. It is cookieless by default and writes nothing to the visitor's device. The anonymous visitor id is a salted hash of IP, user agent and project id, and the salt rotates daily at midnight UTC. You remain the data controller and decide what consent your own use case requires.

Where is the event data stored?

Event data is stored in EU data centres in Germany. Privytics is a managed service built on the open-source OpenPanel engine and is not affiliated with or endorsed by OpenPanel.