Skip to main content
In a Vue app, the simplest way to install Radar is to paste the script into the HTML file that hosts your app. Every screen of the app is served from that one file, so the script loads everywhere. Replace pk_xxxx with your project key. The file is index.html at the root of a Vite project, and public/index.html in a Vue CLI project.
index.html
For what each attribute does, see how the script works.

Alternative: your head manager

If your app already manages the document head with a library, add the script there. Both examples skip the script when no key is set.
With @unhead/vue already set up in your app, call useHead in your root component:
src/App.vue

Alternative: load it from a composable

A composable can add the script to the page when your root component mounts. It does nothing when the key is missing or when the script is already on the page.
src/composables/useRadar.ts
Call it once, in your root component:
src/App.vue

Keep the key out of development

With a head manager or the composable, store the key in an environment file and leave it empty for development. Without a key, the script is not added to the page, so Radar does not load while you develop.
Vite only exposes variables whose name starts with VITE_. With Vue CLI, name the variable VUE_APP_RADAR_PROJECT_KEY and read it with process.env.VUE_APP_RADAR_PROJECT_KEY.

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.