nuxt-modules/plausible
nuxt-modules/plausible has 121 GitHub stars and 7 forks. GitHot measured 0 stars in 24 hours, 0 in 7 days, and 0 in 15 days. Last checked 2026-11-20 21:58 UTC. Last push 2026-11-14.
What you can do
- 🌻 No configuration necessary
- 📯 Track events and page views manually with composables
- 📊 Automatic tracking of outbound links, file downloads and form submissions
- 🔀 Optional API proxy to avoid ad blockers
Progression mesurée des étoiles
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- Historique en cours
Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.
À propos
🎟️ Privacy-friendly web analytics for Nuxt, powered by Plausible
DonnéesREADME.md
Original
Nuxt Plausible
Privacy-friendly web analytics for Nuxt, powered by Plausible.
Features
- 🌻 No configuration necessary
- 📯 Track events and page views manually with composables
- 📊 Automatic tracking of outbound links, file downloads and form submissions
- 🔀 Optional API proxy to avoid ad blockers
- 📂
.envfile support - 🦾 SSR-ready
Setup
npx nuxt module add plausible
Basic Usage
Add @nuxtjs/plausible to the modules section of your Nuxt configuration:
// `nuxt.config.ts`
export default defineNuxtConfig({
modules: ['@nuxtjs/plausible'],
})
Done! Plausible will now run in your application's client.
[!TIP] By default,
@nuxtjs/plausibleuseswindow.location.hostnameas the Plausibledomain. Set thedomainoption to override it.
Configuration
All supported module options can be configured using the plausible key in your Nuxt configuration:
export default defineNuxtConfig({
plausible: {
// Skip tracking on the staging domain as well as localhost
ignoredHostnames: ['localhost', 'staging.example.com'],
},
})
[!TIP] To allow tracking events on localhost, set the
ignoredHostnamesoption to an empty array.
Runtime Config
Alternatively, set options in your project's .env file – Nuxt replaces public runtime config values with matching environment variables at runtime:
# Sets the `plausible.domain` option to `example.com`
NUXT_PUBLIC_PLAUSIBLE_DOMAIN=example.com
With this setup, you can omit the plausible key in your Nuxt configuration.
Proxy Configuration
The proxy routes Plausible events through your Nitro server instead of sending them straight to Plausible's servers, which keeps ad blockers from blocking requests to Plausible's domain.
To enable the proxy, set the proxy option to true:
export default defineNuxtConfig({
plausible: {
proxy: true,
},
})
[!NOTE] The route is
/_plausible/api/event. Settingenabledtofalseswitches it off along with the tracker, so a build with tracking disabled exposes no forwarder.
Because the proxy answers on your own origin, the browser attaches the cookies your site has set. Only the headers Plausible reads travel on: the user-agent, which it attributes the visitor and their device by, the content-type of the event, and an x-forwarded-for carrying the visitor's IP address, which Plausible resolves the country from. Your cookies stay on your server.
The route answers 413 for a body over 8 KB. A Plausible event is a few hundred bytes, and the route takes no authentication.
[!IMPORTANT] Up to v3 the proxy forwarded every header of the incoming request. If you counted on one beyond these three reaching Plausible, it no longer travels.
Enhanced Tracking
The official Plausible tracker tracks outbound link clicks, file downloads and form submissions:
export default defineNuxtConfig({
plausible: {
autoOutboundTracking: true,
fileDownloads: true,
formSubmissions: true,
},
})
File download tracking covers common file types (pdf, xlsx, docx, zip, etc.) unless you name extensions yourself:
export default defineNuxtConfig({
plausible: {
fileDownloads: { fileExtensions: ['pdf', 'zip', 'csv'] },
},
})
[!NOTE] These features require the corresponding goals to be configured in your Plausible dashboard. Outbound link clicks are tracked as
Outbound Link: Click, file downloads asFile Downloadand form submissions asForm: Submission.
Module Options
| Option | Type | Default | Description |
|---|---|---|---|
enabled |
boolean |
true |
Whether the tracker shall be enabled. |
hashMode |
boolean |
false |
Whether page views shall be tracked when the URL hash changes. Enable this if your Nuxt app uses hash-based routing. |
domain |
string |
'window.location.hostname' |
The domain to bind tracking events to. |
ignoredHostnames |
string[] |
['localhost'] |
Hostnames to ignore when tracking events. |
ignoreSubDomains |
boolean |
false |
Also ignore subdomains of ignoredHostnames. Has no effect on localhost, so it does nothing until you add a hostname of your own. |
apiHost |
string |
'https://plausible.io' |
The API host to send events to. |
autoPageviews |
boolean |
true |
Track page views automatically. Disable this if you want to manually manage pageview tracking. |
autoOutboundTracking |
boolean |
false |
Track outbound link clicks automatically. |
fileDownloads |
boolean | { fileExtensions: string[] } |
false |
Track file downloads automatically. Pass an object to customize tracked file extensions. |
formSubmissions |
boolean |
false |
Track form submissions automatically. |
logIgnoredEvents |
boolean |
false |
Log ignored events to the console. |
proxy |
boolean |
false |
Route events through your own origin instead of the Plausible API host. See Proxy Configuration. |
proxyBaseEndpoint |
string |
'/_plausible' |
Base path the proxy answers on. The event route sits below it, at /_plausible/api/event. |
Composables
The composables are auto-imported.
[!NOTE] Since the Plausible instance is only available on the client, executing the composables on the server will have no effect.
useTrackEvent
Track a custom event. Pass a goal's name as eventName to record that goal.
Type Declarations
function useTrackEvent(
eventName: string,
options?: PlausibleEventOptions,
): void
Example
// Tracks the `signup` goal
useTrackEvent('signup')
// Tracks the `Download` goal passing a `method` property
useTrackEvent('Download', { props: { method: 'HTTP' } })
// Tracks the `Purchase` goal with revenue data
useTrackEvent('Purchase', { revenue: { amount: 15.99, currency: 'USD' } })
useTrackPageview
Manually track a page view.
Type Declarations
function useTrackPageview(
options?: PlausibleEventOptions,
): void
Example
useTrackPageview()
// Track with a custom URL
useTrackPageview({ url: '/virtual-page' })
💻 Development
- Clone this repository
- Enable Corepack using
corepack enable - Install dependencies using
pnpm install - Run
pnpm run dev:prepare - Start development server using
pnpm run dev
License
MIT License © 2022-PRESENT Johann Schopplich