Skip to content
Install guide · Frameworks

Install Linqry on Nuxt

To add Linqry to Nuxt, list two scripts under `app.head.script` in `nuxt.config.ts`: an inline queue stub and the tracker with your site ID. Nuxt renders them into the `<head>` of every page, and the tracker counts each client-side navigation as a page view on its own.

Updated · 2 min read

Install with nuxt.config.ts

  1. Get your site ID

    Start a free trial, add your production domain and copy the site ID from the Install page.

  2. Add the scripts to app.head

    app.head sets default <head> tags for every page. Each object in script becomes one <script> element: innerHTML is the inline body, and other keys, including defer and data-* attributes, become attributes on the tag.

    // nuxt.config.ts
    export default defineNuxtConfig({
      app: {
        head: {
          script: [
            { innerHTML: "window.linqry=window.linqry||function(){(window.linqry.q=window.linqry.q||[]).push(arguments)}" },
            {
              src: "https://linqry.com/t.js",
              defer: true,
              "data-website-id": "YOUR_SITE_ID",
              "data-domain": "yourdomain.com",
            },
          ],
        },
      },
    });
  3. Deploy and check Realtime

    Deploy, open the live site and navigate between a few pages. Realtime in Linqry lists each one as a pageview in the live event stream.

Before deploying, you can confirm the output: run a production build, open any page and view its source. You should see both tags in <head>, with data-website-id on the tracker. If the attribute is missing, check the quotes around the hyphenated keys.

SSR, static generation and route changes

Because the tags are part of the server-rendered HTML, the tracker starts loading before your app hydrates, whether you deploy with server rendering, static generation or a hybrid setup. After that, Vue Router changes the URL through the History API. The tracker hooks history.pushState and replaceState and listens for popstate, so every navigation becomes a page view and the time spent on the previous page is reported when it's left. Don't add a router afterEach hook to send page views yourself; you'd count every page twice.

If you run Nuxt as a client-only SPA with router: { options: { hashMode: true } }, routes live in the URL hash. Add "data-hash-routing": true to the tracker entry so hash changes count as navigations.

Alternative: useHead in app.vue

If you'd rather keep the snippet next to your root component, useHead in app.vue accepts the same script array. Use one approach, not both, or the tracker loads twice.

<!-- app.vue -->
<script setup lang="ts">
useHead({
  script: [
    { innerHTML: "window.linqry=window.linqry||function(){(window.linqry.q=window.linqry.q||[]).push(arguments)}" },
    { src: "https://linqry.com/t.js", defer: true, "data-website-id": "YOUR_SITE_ID", "data-domain": "yourdomain.com" },
  ],
});
</script>

<template>
  <NuxtPage />
</template>

Custom events

In components, call window.linqry from a function in <script setup>. Guard it with import.meta.client (or call it only from event handlers, which never run on the server):

<script setup lang="ts">
function onTrialStart() {
  if (import.meta.client) window.linqry?.("trial-started", { plan: "starter" });
}
</script>

<template>
  <button @click="onTrialStart">Start trial</button>
</template>

For the type, add the declaration below to a .d.ts file in your project. Events can be turned into goals and funnel steps; custom events covers naming rules and property limits. Revenue from payments is better sent from a Nitro server route with the site's write key, using the tracking API.

// linqry.d.ts (anywhere your tsconfig includes)
export {};

declare global {
  interface Window {
    linqry?: (
      event: string,
      props?: Record<string, string | number | boolean>,
      revenueCents?: number,
    ) => void;
  }
}

Excluding development and your own visits

The Nuxt dev server runs on localhost, and Linqry ignores events from localhost. Staging hostnames are rejected unless you list them under Additional hosts in site Settings. To stop counting yourself on production, run this in the browser console on your live site:

localStorage.setItem('linqry_ignore', 'true')

Troubleshooting

  • Page views doubled? The snippet is probably in both nuxt.config.ts and useHead, or a router hook also sends page views. Keep one.
  • Security headers module? If you send a Content-Security-Policy, allow https://linqry.com in script-src and connect-src.
  • Still nothing? Check that the site ID matches the Install page and test in a browser without an ad blocker.

Frequently asked questions

Is there a Nuxt module for Linqry?

No. Linqry doesn't publish a Nuxt module, and you don't need one: two entries in app.head.script are the whole install.

Does it work with Nuxt 3 and Nuxt 4?

Yes. Both use app.head in nuxt.config.ts and useHead in components, and the tracker itself doesn't depend on Nuxt.

Sources

  1. Nuxt: Configuration reference (app.head) (checked Nov 9, 2026)
  2. Nuxt: SEO and Meta (useHead, script entries) (checked Nov 9, 2026)
  3. Nuxt: Custom routing (hash mode) (checked Nov 9, 2026)

Start measuring your Nuxt site

No card required · 30-day trial · No cookies