Install Linqry on a Vue app
To add Linqry to a Vue app, paste the two-line snippet into the `<head>` of `index.html` at your project root. Every Vue Router navigation is recorded as a page view automatically; if you use hash mode, add one attribute.
Updated · 2 min read
Install in three steps
- Create the site in Linqry
Start a free trial, add your production domain and open the Install page for your site ID.
- Paste the snippet into index.html
Projects created with
create-vueor the Vitevuetemplate keepindex.htmlat the project root. Add the snippet inside<head>.<!-- index.html --> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>My Vue app</title> <script>window.linqry=window.linqry||function(){(window.linqry.q=window.linqry.q||[]).push(arguments)}</script> <script defer data-website-id="YOUR_SITE_ID" data-domain="yourdomain.com" src="https://linqry.com/t.js"></script> </head> <body> <div id="app"></div> <script type="module" src="/src/main.ts"></script> </body> </html> - Deploy and verify
Open the deployed app, click through a few routes, then open Realtime in Linqry. Each route shows up as a
pageviewin the live event stream.
Vue Router: history mode vs hash mode
With createWebHistory(), URLs look like normal paths (/pricing) and Vue Router changes them through the History API. The tracker hooks history.pushState and replaceState and listens for popstate, so nothing else is needed: each navigation is a page view and the time spent on the previous route is reported when it's left.
With createWebHashHistory(), the route lives after a # (/#/pricing). By default the tracker treats hash changes as in-page jumps, not navigations, so add data-hash-routing:
<script defer data-website-id="YOUR_SITE_ID" data-domain="yourdomain.com" data-hash-routing src="https://linqry.com/t.js"></script>
| Router history | Example URL | Extra attribute |
|---|---|---|
createWebHistory() | /pricing | None |
createWebHashHistory() | /#/pricing | data-hash-routing |
createMemoryHistory() | URL doesn't change | Not suitable for page tracking; send events manually |
What's recorded without any code
- Page views for the first load and every router navigation, with the referrer and any UTM parameters from the landing URL.
- Time on page, sent when a visitor navigates to another route, switches tabs or closes the page.
- Outbound clicks on links to other domains, recorded as
outboundevents with the destination URL. - Country, device, browser and OS, derived on the server. No cookies are set and nothing is stored in the visitor's browser; see the privacy model.
Custom events from components
Call window.linqry from a function in <script setup> rather than directly in the template. Vue sandboxes template expressions to a short list of built-in globals, and properties you attach to window aren't on it:
<script setup lang="ts">
function trackDemoRequest() {
window.linqry?.("demo-requested", { page: "pricing" });
}
</script>
<template>
<button @click="trackDemoRequest">Book a demo</button>
</template>Add the declaration below once for type checking. For clicks that only need a name, the attribute form works too: <a href="/signup" data-linqry-event="signup-clicked">. Events you send can be used as goals and funnel steps; see custom events for limits on names and properties.
// linqry.d.ts (anywhere your tsconfig includes)
export {};
declare global {
interface Window {
linqry?: (
event: string,
props?: Record<string, string | number | boolean>,
revenueCents?: number,
) => void;
}
}Exclude your own visits and test environments
Events from localhost are ignored, so npm run dev never shows up in your stats. Staging hostnames are rejected unless you add them under Additional hosts in site Settings. To stop counting yourself on production, run this in the console on your live site once:
localStorage.setItem('linqry_ignore', 'true')Troubleshooting
- Only the landing page is counted? You're probably in hash mode without
data-hash-routing. - Nothing recorded? Check the deployed
index.htmlreally contains the snippet and that the site ID matches the Install page. Ad blockers can block analytics scripts, so test in a clean browser profile. - Server-rendered Vue? If Nuxt renders your pages, use the Nuxt guide instead.
Frequently asked questions
Do I need a Vue plugin?
No. Linqry has no Vue plugin; the script tag in index.html handles page views on its own, and window.linqry covers custom events.
Does it work if my Vue app isn't built with Vite?
Yes. The tracker doesn't depend on Vue or on the build tool. Put the snippet in whichever HTML file serves your app, and the same router rule applies: hash-mode routes need data-hash-routing.
Why do two visits to the same page in one session count twice?
Every navigation is a page view, just as in a server-rendered site. Unique visitors are counted separately, once per visitor per day.
Sources
- Vue Router: Different history modes (checked Nov 9, 2026)
- Vue: Template syntax (restricted globals access) (checked Nov 9, 2026)
- Vite: Getting started (index.html as the entry point) (checked Nov 9, 2026)
Related
Add two entries to app.head.script in nuxt.config.ts. Works with SSR, static generation and client-side navigation.
Paste the snippet into index.html in a Vite or other React SPA. React Router navigations are tracked as page views.
Send events from JavaScript or plain HTML attributes — plus the events Linqry records for you automatically.
Build a funnel from any custom events or URL paths and see how many visitors reach each step and where they drop off.
Start measuring your Vue site
No card required · 30-day trial · No cookies