---
title: "Plausible Analytics · Nuxt Scripts"
description: "Load Plausible's site-specific tracker, including custom self-hosted endpoints."
canonical_url: "https://scripts.nuxt.com/scripts/plausible-analytics"
meta:
  "og:description": "Load Plausible's site-specific tracker, including custom self-hosted endpoints."
  "og:image": "https://scripts.nuxt.com/_og/s/o_bef8ccff2565a1cb.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Plausible Analytics · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_bef8ccff2565a1cb.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Scripts**

# **Plausible Analytics**

[Copy for LLMs](https://scripts.nuxt.com/scripts/plausible-analytics.md)

[**Plausible Analytics**](https://plausible.io/) is a privacy-focused web analytics platform. This registry entry supports its current site-specific script.

**Plausible Analytics**

[**View source **](https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/registry/plausible-analytics.ts)

## Nuxt Config Setup

Add this to your `**nuxt.config.ts**` to load Plausible Analytics globally. Alternatively you can use the **useScriptPlausibleAnalytics** composable for more control.

```
export default defineNuxtConfig({
  scripts: {
    registry: {
      plausibleAnalytics: {
        domain: 'example.com',
        trigger: 'onNuxtReady',
      }
    }
  }
})
```

This config automatically enables **first-party mode ** (bundle + proxy). See below to customise.

## useScriptPlausibleAnalytics()

The `**useScriptPlausibleAnalytics**` composable lets you have fine-grain control over when and how Plausible Analytics is loaded on your site.

```
const { proxy } = useScriptPlausibleAnalytics()

proxy.plausible('conversion', { props: { value: 1 } })
```

Please follow the [**Registry Scripts **](https://scripts.nuxt.com/docs/guides/registry-scripts) guide to learn more about advanced usage.

## First-Party Mode: Privacy Focused Proxy

No extra config needed. The script is bundled from your domain (faster loads, no extra DNS lookup) and runtime requests are reverse-proxied through your server with automatic anonymisation (user IPs stay hidden from Plausible Analytics, works with ad blockers). [**Learn more. **](https://scripts.nuxt.com/docs/guides/first-party)

**Mode**

Bundle Proxy Partytown

**Privacy**

User IP addresses are anonymised. Other request data passes through.

```
export default defineNuxtConfig({
  scripts: {
    // ✅ First-party mode: bundled + proxied
    registry: {
      plausibleAnalytics: {
        domain: 'example.com',
        trigger: 'onNuxtReady',
      },
    },
  },
})
```

## Example

Using Plausible Analytics in a component with the proxy to send events .

ConversionButton.vue

```
<script setup lang="ts">
const { proxy } = useScriptPlausibleAnalytics()

// noop in development, ssr
// just works in production, client
function handleAction() {
  proxy.plausible('conversion', { props: { value: 1 } })
}
</script>

<template>
  <div>
    <button @click="handleAction">
      Send Event
    </button>
  </div>
</template>
```

### Self-hosted Plausible

If you use a self-hosted version of Plausible, provide both the script URL and the event endpoint. Changing the script URL alone does not change the endpoint passed to Plausible.

```ts
useScriptPlausibleAnalytics({
  scriptId: 'YOUR_SCRIPT_ID',
  endpoint: 'https://my-self-hosted-plausible.io/api/event',
  scriptInput: {
    src: 'https://my-self-hosted-plausible.io/js/script.js'
  }
})
```

For Plausible Cloud, find the `**scriptId**` under **Site Installation** in your site settings. Plausible's [**script update guide**](https://plausible.io/docs/script-update-guide) explains the site-specific URL and `**plausible.init()**` options.

### Extract a Script ID

A current Plausible installation tag looks like this:

```html
<script async src="https://plausible.io/js/pa-gYyxvZhkMzdzXBAtSeSNz.js"></script>
```

Your `**scriptId**` is the part after `**pa-**` and before `**.js**`:

```ts
scriptId: 'gYyxvZhkMzdzXBAtSeSNz'
//         ^^^^^^^^^^^^^^^^^^^^^^^
//         Extract from: pa-{scriptId}.js
```

```
export interface PlausibleAnalyticsOptions {
  /**
   * Unique script ID for your site.
   * Get this from your Plausible dashboard under Site Installation
   *
   * Extract it from your Plausible script URL:
   * ```
   * <script src="https://plausible.io/js/pa-gYyxvZhkMzdzXBAtSeSNz.js"></script>
   *                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^
   *                                       scriptId: 'gYyxvZhkMzdzXBAtSeSNz'
   * ```
   * @example 'gYyxvZhkMzdzXBAtSeSNz'
   */
  scriptId: string
  /** Custom properties to track with every pageview */
  customProperties?: Record<string, any>
  /** Custom tracking endpoint URL */
  endpoint?: string
  /** Configure file download tracking */
  fileDownloads?: {
    /** File extensions to track (default: pdf, xlsx, docx, txt, rtf, csv, exe, key, pps, ppt, pptx, 7z, pkg, rar, gz, zip, avi, mov, mp4, mpeg, wmv, midi, mp3, wav, wma, dmg) */
    fileExtensions?: string[]
  }
  /** Enable hash-based routing for single-page apps */
  hashBasedRouting?: boolean
  /** Set to false to manually trigger pageviews */
  autoCapturePageviews?: boolean
  /** Enable tracking on localhost */
  captureOnLocalhost?: boolean
  /** Enable form submission tracking */
  trackForms?: boolean
}
```

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/plausible-analytics.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/plausible-analytics.md)

[**PayPal** Load PayPal's JavaScript SDK v6 and create checkout or messaging sessions from Vue components.](https://scripts.nuxt.com/scripts/paypal) [**PostHog** Load posthog-js with first-party proxy support, feature flags, and opt-in or opt-out controls.](https://scripts.nuxt.com/scripts/posthog)

**On this page **

- [Self-hosted Plausible](#self-hosted-plausible)
- [Extract a Script ID](#extract-a-script-id)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/plausible-analytics#webpage","@type":"WebPage","description":"Load Plausible's site-specific tracker, including custom self-hosted endpoints.","name":"Plausible Analytics","url":"https://scripts.nuxt.com/scripts/plausible-analytics","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/plausible-analytics#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/plausible-analytics"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/plausible-analytics#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"Plausible Analytics","item":"https://scripts.nuxt.com/scripts/plausible-analytics","position":3}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
