vTilt
By roleFoundersKnow what to fix firstMarketersSee what happens after the clickCMOsSee what your budget really buys
By businessSaaSTurn signups into active usersEcommerceSee why shoppers abandon cartsAgenciesProve your work to clientsEnterpriseOne customer record for every team
MeasureWeb AnalyticsFind where buyers leaveSession ReplaySee why they left, not just that they didAdsKnow what paid visitors do nextIntegrationsOne snippet feeds your stack
ThinkPeopleOne profile per customerCustomer MemoryvTilt remembers every visitorSite KnowledgeAnswers and audits from your own pages
ActAsk AIAnswers from real behaviorAI ChatChat that knows the visitorEmail CampaignsEmail from real visits
PricingWhy vTiltDocs
Docs / Vue.js
Getting Started
OverviewInstallInitializeIdentify usersTrack eventsLogout & resetVerify eventsCommon mistakes
Guides
Event forwardingReverse proxyRealtime dashboardSite knowledge
Frontend frameworks
Next.jsNuxt.jsVue.jsReactReact RouterRemixGatsbySvelte / SvelteKitAstroAngularTanStack StartDocusaurus
Backend frameworks
NestJSHonoCloudflare WorkersDjangoFlaskLaravelPhoenixRuby on Rails
Backend languages
PythonPHPRubyElixirGoJava.NET / C#Rust
Stack guides
Vue + PHP
API Reference
Browser SDK
Script bundlesAutocaptureWeb VitalsSession recordingChat widgetFeature readinessRemote configurationDebug logging
Node SDK
Install & setupCapture, identify & aliasContext & shutdownGlobal properties & opt-outError tracking
MCP server
Guides
OverviewAuthenticationOAuthAgent skills (prompts)AI intelligenceSite knowledgeGoogle AdsMeta Ads
Client setup
CursorClaude DesktopVS CodeCodex

Getting Started

OverviewInstallInitializeIdentify usersTrack eventsLogout & resetVerify eventsCommon mistakes

Guides

Event forwardingReverse proxyRealtime dashboardSite knowledge
Next.jsNuxt.jsVue.jsReactReact RouterRemixGatsbySvelte / SvelteKitAstroAngularTanStack StartDocusaurus

API Reference

MCP server

On this page

On this page

  • 1. Add your environment variables
  • 2. Install & initialise
  • 3. Vue Router pageviews
  • 4. Use vt from any component
  • 5. Identify users
  • 6. Logout
  • Next steps
DocsGuidesFrontend frameworksVue.js

Vue.js

Last updated July 22, 2026

Integrate vTilt with a standalone Vue 3 app — npm package or inline script, Vue Router pageviews, identify on page load.

vTilt drops into a standalone Vue 3 app (Vite, vue-cli, Vue + Vite SPA). If you have a server-rendered shell, see the Vue + PHP guide for the SSR identify pattern.

#1. Add your environment variables

# .env
VITE_VTILT_TOKEN=YOUR_PROJECT_TOKEN
VITE_VTILT_HOST=https://www.vtilt.com
text

#2. Install & initialise

Choose how you load the Browser SDK. npm initialises the SDK in main.ts; the inline script drops a stub in index.html with no package to install. Both expose the same window.vt global — the rest of this guide is identical either way.

Install the package:

npm install @v-tilt/browser
bash

Boot the SDK before mounting the app so the first paint is captured:

// src/main.ts
import { createApp } from 'vue'
import { vt } from '@v-tilt/browser'
import App from './App.vue'
import { router } from './router'

vt.init(import.meta.env.VITE_VTILT_TOKEN, {
  api_host: import.meta.env.VITE_VTILT_HOST,
  autocapture: true,
  capture_pageview: true,
  capture_pageleave: true,
})

const app = createApp(App)
app.config.globalProperties.$vt = vt
app.provide('vt', vt)
app.use(router)
app.mount('#app')
typescript

Tip

Need chat on first paint? Swap array.js for array.chat.js and add chat: { enabled: true }. See Script bundles.

#3. Vue Router pageviews

With the standard History API, the SDK patches pushState / replaceState so SPA navigation works automatically. The manual afterEach below is only needed when you bypass it (custom routers, hash-mode). Disable capture_pageview first to avoid double-counting.

// src/router.ts
import { createRouter, createWebHistory } from 'vue-router'
import { vt } from '@v-tilt/browser'

export const router = createRouter({
  history: createWebHistory(),
  routes: [
    /* ... */
  ],
})

router.afterEach((to, from, failure) => {
  if (failure) return
  vt.capture('$pageview', {
    $current_url: window.location.href,
    $pathname: to.fullPath,
    $referrer: from.fullPath,
  })
})
typescript

#4. Use vt from any component

<script setup lang="ts">
import { inject } from 'vue'
import type { vt as VtType } from '@v-tilt/browser'

const vt = inject<typeof VtType>('vt')!

function trackCta() {
  vt.capture('cta_clicked', { location: 'hero' })
}
</script>

<template>
  <button @click="trackCta">Get started</button>
</template>
vue

#5. Identify users

Important

Don't only identify inside your login handler. Visitors arriving with an existing session cookie stay anonymous unless you also identify after auth finishes loading.

// src/plugins/vtilt-identity.ts
import { watch } from 'vue'
import { useUserStore } from './stores/user'

export function setupVtiltIdentity() {
  const store = useUserStore()

  watch(
    () => [store.user, store.isReady] as const,
    ([user, isReady]) => {
      if (!isReady) return
      const vt = window.vt
      if (!vt) return
      if (user?.id) {
        vt.identify(user.id, {
          email: user.email,
          name: user.name,
          plan: user.plan,
        })
      } else if (vt.getUserState() === 'identified') {
        vt.resetUser()
      }
    },
    { immediate: true },
  )
}
typescript

Call setupVtiltIdentity() from App.vue setup(). Your store must expose isReady (or equivalent) so you do not reset anonymous visitors while the session is still hydrating. See Identify & alias for the full model.

#6. Logout

import { vt } from '@v-tilt/browser'

async function logout() {
  vt.capture('user_logged_out')
  vt.resetUser()
  await fetch('/api/auth/logout', { method: 'POST' })
  window.location.href = '/'
}
typescript

#Next steps

  • Vue + PHP integration guide — full server-rendered identify pattern.
  • Nuxt.js integration guide — same SDK with Nuxt's runtime config + plugins.
  • Identify & alias — anonymous → known user merge.
  • Autocapture — what's captured automatically.
  • Common mistakes — integration pitfalls to avoid before you ship.
PreviousNuxt.jsIntegration guidesNextReactIntegration guides