You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Done! Plausible will now run in your application's client.
36
37
37
38
> [!TIP]
38
-
> By default, `@nuxtjs/plausible` will use `window.location.hostname` for the Plausible `domain` configuration key, which should suit most use-cases. If you need to customize the domain, you can do so in the [module options](#module-options).
39
+
> By default, `@nuxtjs/plausible` will use `window.location.hostname` for the Plausible `domain` configuration key, which should suit most usecases. If you need to customize the domain, you can do so in the [module options](#module-options).
39
40
40
41
## Configuration
41
42
@@ -68,9 +69,9 @@ With this setup, you can omit the `plausible` key in your Nuxt configuration.
68
69
69
70
### Proxy Configuration
70
71
71
-
The module provides a proxy API feature that allows you to route Plausible events through your Nitro server instead of sending them directly to Plausible's servers. This is useful if you want to prevent ad blockers from blocking requests to Plausible's domain. When proxy is enabled, the tracker will automatically route requests through the current origin.
72
+
The module provides a proxy feature that routes Plausible events through your Nitro server instead of sending them directly to Plausible's servers. This is useful to prevent ad blockers from blocking requests to Plausible's domain.
72
73
73
-
To enable the proxy API, set the `proxy` option to `true`:
74
+
To enable the proxy, set the `proxy` option to `true`:
> When enabled, all Plausible events will be sent to your server first, which then forwards them to Plausible's API. The default proxy endpoint is `/_plausible`, but you can customize the path using the `proxyBaseEndpoint` module option.
87
88
89
+
### Enhanced Tracking
90
+
91
+
The module supports automatic tracking of outbound link clicks, file downloads, and form submissions – all powered by the [official Plausible tracker](https://github.com/plausible/analytics/tree/master/tracker).
92
+
93
+
```ts
94
+
exportdefaultdefineNuxtConfig({
95
+
modules: ['@nuxtjs/plausible'],
96
+
97
+
plausible: {
98
+
autoOutboundTracking: true,
99
+
fileDownloads: true,
100
+
formSubmissions: true,
101
+
},
102
+
})
103
+
```
104
+
105
+
By default, file download tracking covers common file types (pdf, xlsx, docx, zip, etc.). You can customize which file extensions are tracked:
> These features require the corresponding goals to be configured in your [Plausible dashboard](https://plausible.io/docs/custom-event-goals). Outbound link clicks are tracked as `Outbound Link: Click`, file downloads as `File Download`, and form submissions as `Form: Submission`.
|`enabled`|`boolean`|`true`| Whether the tracker shall be enabled. |
93
-
|`hashMode`|`boolean`|`false`| Whether page views shall be tracked when the URL hash changes. Enable this if your Nuxt app uses the `hashMode` router option instead of the default history mode. |
94
-
|`domain`|`string`|`'window.location.hostname'`| The domain to bind tracking event to. |
95
-
|`ignoredHostnames`|`string[]`|`['localhost']`| Hostnames to ignore when tracking events. |
96
-
|`ignoreSubDomains`|`boolean`|`false`| Ignore the hostname if it is a subdomain of `ignoredHostnames`. |
97
-
|`apiHost`|`string`|`https://plausible.io`| The API host where the events will be sent to. |
98
-
|`autoPageviews`|`boolean`|`true`| Track the current page and all further pages automatically. Disable this if you want to manually manage pageview tracking. |
99
-
|`autoOutboundTracking`|`boolean`|`false`| Track all outbound link clicks automatically. If enabled, a [MutationObserver](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) automagically detects link nodes throughout the application and binds `click` events to them. |
100
-
|`logIgnoredEvents`|`boolean`|`false`| Log events to the console if they are ignored. |
101
-
|`proxy`|`boolean`|`false`| Whether to proxy the event endpoint through the current origin. |
102
-
|`proxyBaseEndpoint`|`string`|`'/_plausible'`| The base endpoint to proxy the Plausible event endpoint through. |
Passoptionaleventdatatobesentwiththe`eventData`argument. Defaultstothecurrentpage's data merged with the default options provided during the Plausible initialization.
140
-
141
172
**TypeDeclarations**
142
173
143
174
```ts
144
175
function useTrackPageview(
145
-
eventData?: PlausibleOptions,
146
-
options?: EventOptions,
176
+
options?: PlausibleEventOptions,
147
177
): void
148
178
```
149
179
180
+
**Example**
181
+
182
+
```ts
183
+
useTrackPageview()
184
+
185
+
// Track with a custom URL
186
+
useTrackPageview({ url: '/virtual-page' })
187
+
```
188
+
150
189
## 💻 Development
151
190
152
191
1.Clonethisrepository
@@ -155,10 +194,6 @@ function useTrackPageview(
155
194
4.Run`pnpm run dev:prepare`
156
195
5.Startdevelopmentserverusing`pnpm run dev`
157
196
158
-
## Credits
159
-
160
-
- [@Barbapapazes](https://github.com/Barbapapazes) for his [Plausible tracker rewrite](https://github.com/Barbapapazes/plausible-tracker)
0 commit comments