Documentation
Set up Privatrak, name what matters to you and read every report.
Install on Nuxt
The Nuxt module @privatrak/nuxt adds cookieless, privacy-friendly analytics to your Nuxt app. It records page views, clicks and form submissions, route changes included, and it reports the AI services and crawlers that read your pages.
You install the module and put your website key in nuxt.config.ts. Your first page views arrive in Privatrak within a few seconds.
Before you start
- A Privatrak project for your site. Getting started shows how to create one.
- Nuxt 3 or newer.
- Your website key, the key of the type Your website. Copy it under Settings › API Keys. It can only send data, so it is safe to put in your app.
Add analytics to your Nuxt app
- Install the module:
npm install @privatrak/nuxt - Add it to
modulesinnuxt.config.ts. Put your website key andapiHostundertracker:// nuxt.config.ts export default defineNuxtConfig({ modules: ['@privatrak/nuxt'], tracker: { apiKey: 'your-website-key', apiHost: 'https://api.privatrak.com', }, }); - Start your app and open a page.
Page views arrive, and so does every route change, click and form submission.
To set the key for each environment without building again, use the environment variable NUXT_PUBLIC_TRACKER_API_KEY.
Change what the tracker records
The tracker block takes the tracker’s options next to apiKey and apiHost:
export default defineNuxtConfig({
modules: ['@privatrak/nuxt'],
tracker: {
apiKey: 'your-website-key',
apiHost: 'https://api.privatrak.com',
autocapture: false,
excludedUrls: ['/admin/*'],
traits: ['beta'],
},
});Options you leave out follow your project’s settings under Settings › Tracker. The Tracker reference lists every option.
Name actions in your code
Add data-track to a button or link. Privatrak then shows it as a feature, a name for something people do on your site, here signup-cta:
<template>
<button data-track="signup-cta" data-track-plan="pro">Sign up</button>
</template>To record an event from code, use useTracker(). Nuxt imports it for you. track() sends an event, and setTraits() gives the visit a list of traits, such as a plan:
<script setup lang="ts">
const { track, setTraits } = useTracker();
function onCheckout(): void {
track('checkout-completed', { plan: 'pro' });
}
setTraits(['paid', 'admin']);
</script>Both do nothing during server-side rendering, so you can call them in code that also runs on the server. Name things in your code has more examples.
Report AI services and crawlers
AI services such as ChatGPT and Claude read your pages without running JavaScript, so the tracker never sees them. The module reports their requests from your Nuxt server, and the AI services page shows how often each one read your pages. It is on as soon as your website key is set, so there is nothing more to set up. It never delays or fails a response.
The module reports crawler requests for pages, robots.txt, sitemaps and llms.txt. Assets under /_nuxt/, images and your /api/ routes are not reported.
It works with every Nitro preset that has a server: Node, Vercel, Vercel Edge, Netlify, Cloudflare Pages and Workers, Bun and Deno. A site built with nuxi generate has no server, so there is nothing to report.
On Netlify, set a compatibilityDate in nuxt.config.ts, so that a function does not stop before a report is sent.
To turn it off, set serverRequests: false in the tracker block:
export default defineNuxtConfig({
modules: ['@privatrak/nuxt'],
tracker: {
apiKey: 'your-website-key',
apiHost: 'https://api.privatrak.com',
serverRequests: false,
},
});You can also set NUXT_TRACKER_SERVER_REQUESTS=false in the server’s environment.
If you already report server requests another way, for example with a Cloudflare Worker, use only one of them, or each request counts twice. Report server requests explains how.
What Privatrak records on Nuxt
In the browser, Privatrak records page views, clicks, form submissions and the events you send with track(). It never reads what a visitor types into a form. It sets no cookies, so you need no cookie banner. Privacy explains how visitors are counted.
From your server, Privatrak receives only requests from known crawlers. For each request that is the crawler’s user agent, the page address and the time. Nothing about your visitors leaves your server. What leaves your server has the details.
Check that it works
Check page views
- Open a page of your site in your browser.
- In Privatrak, open Events and click Refresh events.
Your page view is the top row, with the type Pageview. If nothing arrives, open your browser’s console. The tracker says there what went wrong, and When nothing is sent tells you what to do.
Check crawler requests
- Request a page of your live site the way an AI service would. Replace the address with your own:
curl -A "ChatGPT-User/1.0" https://example.com/ - In Privatrak, open AI services and switch to the tab All crawlers.
ChatGPT-User (OpenAI) appears under AI answers with 1 request. This test request counts like a real one. If nothing appears, check that your website key is set, that your site’s domain is in your allowed domains, that your site runs on a server, and that no cache answered the request.
Next steps
- Features: see how often each named action is used.
- AI services: see which AI services read which of your pages.
- Funnels: see where visitors drop off on the way to a goal.
- Tracker reference: every option and function, to look up.