All guides

Install Foresite on Nuxt

Add the Tracking Script to every page's <head> in nuxt.config.ts:

export default defineNuxtConfig({
  app: {
    head: {
      script: [{ src: 'https://t.foresite.dev/s/YOUR_SITE_ID.js', defer: true }],
    },
  },
})

Use the address from your own Foresite line (Settings → Install). If you set up a custom domain, it starts with your own subdomain instead of t.foresite.dev.

This works for server-rendered, static (nuxt generate) and single-page Nuxt sites. Foresite counts each page change as a pageview automatically. Visits to localhost aren't counted, so test on your deployed site: the Installation Check in Settings → Install turns green with the first pageview.

To count signups, purchases and other actions, call window.foresite() in the browser; see custom events.