Skip to main content
In a Nuxt project, the simplest way to install Radar is to declare the script in nuxt.config.ts. Nuxt then adds it to the <head> of every page. Replace pk_xxxx with your project key.
nuxt.config.ts
For what each attribute does, see how the script works.

Alternative: useHead with runtime config

Use this version when you want to read the project key from an environment variable and skip the script when the key is not set. First declare the key in the public runtime config. Nuxt replaces the empty value with the NUXT_PUBLIC_RADAR_PROJECT_KEY environment variable when it is set.
nuxt.config.ts
Then call useHead in app.vue:
app.vue

Alternative: a client plugin

A plugin keeps the script out of app.vue. It uses the same runtime config as above. The .client.ts suffix tells Nuxt to run the plugin in the browser only, so no import.meta.client check is needed.
plugins/radar.client.ts

Keep the key out of development

With useHead or the plugin, set the key for production only. Without a key, the script is not added to the page, so Radar does not load while you develop. Set this variable in the environment where your site is built and hosted, and leave it out of your local .env file:
Nuxt does not load a .env.production file on its own, so do not rely on one unless your build command points to it.

Check that it works

Deploy your site, open the published version, load two pages and click a link. The first event should reach your Radar dashboard within a few seconds. If nothing arrives, follow check your installation. When the tag is added by JavaScript rather than written in the HTML, it does not show in the raw page source: look for tracker.js in the Elements panel of your browser’s developer tools instead.