Statable Analytics
Statable is cookie-free web analytics. It honours Do Not Track and Global Privacy Control. The tracking script reference lists its options.
This integration needs Statable's standalone tracking script, available on paid plans. The Hobby plan uses a widget bundle and has no separate tracker.
Nuxt Config Setup
Add this to your nuxt.config.ts to load Statable Analytics globally. Alternatively you can use the useScriptStatableAnalytics composable for more control.
export default defineNuxtConfig({
scripts: {
registry: {
statableAnalytics: {
trigger: 'onNuxtReady',
}
}
}
})This config automatically enables first-party mode (bundle). See below to customise.
useScriptStatableAnalytics()
The useScriptStatableAnalytics composable lets you have fine-grain control over when and how Statable Analytics is loaded on your site.
const { proxy } = useScriptStatableAnalytics()Please follow the Registry Scripts guide to learn more about advanced usage.
First-Party Mode: Privacy Focused Proxy
No extra config needed. The script is bundled and served from your domain instead of a third-party CDN, eliminating an extra DNS lookup and improving load times. Learn more.
export default defineNuxtConfig({
scripts: {
// ✅ First-party mode: bundled
registry: {
statableAnalytics: {
trigger: 'onNuxtReady',
},
},
},
})Example
Using Statable Analytics in a component.
<script setup lang="ts">
const { proxy } = useScriptStatableAnalytics()
// noop in development, ssr
// just works in production, client
function handleAction() {
// use proxy methods here
}
</script>
<template>
<div>
<button @click="handleAction">
Send Event
</button>
</div>
</template>Proxying is not supported
Statable uses the connecting IP address and user agent to count visitors. If your Nuxt server relays beacons, Statable sees the server's IP instead.
You can bundle the tracker on your Nuxt origin. Beacons still go to the Statable API. The composable sets the Site ID and API endpoint on the script tag so bundling keeps both values.
Custom host and API endpoint
host selects where Nuxt Scripts fetches the tracker and sets the default beacon endpoint. With bundling, browsers load the tracker from your Nuxt origin. If the custom host relays beacons, set trackingApi to the Statable API so Statable sees each visitor's IP.
useScriptStatableAnalytics({
siteId: 'YOUR_SITE_ID',
host: 'https://stats.example.com',
trackingApi: 'https://statable.com/api/event',
})Custom events
Use proxy.t(name, props) to record an event. Calls made before the tracker loads run once it is ready. Properties can be strings, numbers or booleans.
const { proxy } = useScriptStatableAnalytics()
function trackSignup() {
proxy.t('Sign Up', { plan: 'pro' })
}const { onLoaded } = useScriptStatableAnalytics()
onLoaded(({ t }) => {
t('Purchase', { plan: 'annual', amount: 99 })
})Statable can also track outbound links, downloads and elements with data-statable-event. Enable each module in Statable's Site settings. See the JavaScript API.
Sticky properties
props adds properties to every event. Nuxt Scripts renders them as data-statable-* attributes.
useScriptStatableAnalytics({
siteId: 'YOUR_SITE_ID',
props: { env: 'production', cohort: 'beta' },
})Page views in Nuxt
The tracker counts client-side navigation without extra setup. Enable Statable's engagement module to record time and scroll depth.
siteIdstring required The numeric Site ID from Site settings, Tracking Code, in Statable.
hoststring = 'https://statable.com'Origin used to fetch the tracker and set the default event endpoint. Bundling still serves the script from your Nuxt origin.
trackingApistringEndpoint the tracker posts events to. Defaults to `/api/event` on `host`.
propsRecord<string, string>Custom properties attached to every event from the page load, rendered as `data-statable-*` attributes on the script tag.
Example
The default trigger waits until Nuxt is ready:
<script setup lang="ts">
useScriptStatableAnalytics({
siteId: 'YOUR_SITE_ID',
})
</script>