@@ -18,13 +18,14 @@ export default defineNuxtConfig({
1818 simpleAnalytics: {
1919 hostname: " your-domain.com" ,
2020 enabled: true ,
21- proxy: true ,
2221 },
2322});
2423```
2524
2625## Usage
2726
27+ Adding the module will automatically enable client-side page view collection though the Simple Analytics script.
28+
2829### Server-side Pageview Tracking
2930
3031Track pageviews automatically on the server:
@@ -34,10 +35,7 @@ Track pageviews automatically on the server:
3435// This will run on the server and track the pageview
3536if (import.meta.server) {
3637 await trackPageview({
37- hostname: "your-domain.com",
38- metadata: {
39- source: "homepage",
40- },
38+ some_extra_metadata: "homepage"
4139 });
4240}
4341</script>
@@ -48,14 +46,11 @@ if (import.meta.server) {
4846Track custom events from API routes or server-side code:
4947
5048``` ts
51- // In a server API route
49+ // In a (Nitro) server API route
5250export default defineEventHandler (async (event ) => {
53- await trackEvent (" user_signup" , {
54- event ,
55- metadata: {
56- source: " registration_form" ,
57- user_type: " new" ,
58- },
51+ await trackEvent (event , " user_signup" , {
52+ source: " registration_form" ,
53+ user_type: " new" ,
5954 });
6055
6156 return { success: true };
@@ -75,9 +70,6 @@ export default defineNuxtConfig({
7570 // Enable/disable the module
7671 enabled: true ,
7772
78- // Enable/disable proxy
79- proxy: true ,
80-
8173 // Auto-collect events
8274 autoCollect: true ,
8375
@@ -99,6 +91,9 @@ export default defineNuxtConfig({
9991 screensize: false ,
10092 viewportsize: false ,
10193 language: false ,
94+
95+ // Use vendor specific timezone headers to the determine the visitors location (server only)
96+ timezone: false
10297 },
10398
10499 // Ignore specific pages
@@ -112,6 +107,9 @@ export default defineNuxtConfig({
112107
113108 // Strict UTM parameter parsing
114109 strictUtm: true ,
110+
111+ // Enable enhanced bot detection during server tracking (server only)
112+ enhancedBotDetection: false
115113 },
116114});
117115```
@@ -131,7 +129,7 @@ Track a pageview on the server.
131129
132130** Parameters:**
133131
134- - ` options ` (object): Additional metadata to track (optional)
132+ - ` metadata ` (object): Additional metadata to track (optional)
135133
136134### ` trackEvent(eventName, options) `
137135
@@ -140,40 +138,28 @@ Track a custom event on the server.
140138** Parameters:**
141139
142140- ` eventName ` (string): Name of the event to track
143- - ` options ` (object): Additional metadata to track (option )
141+ - ` metadata ` (object): Additional metadata to track (optional )
144142
145143## API Reference (Nitro)
146144
147- ### ` trackPageview(requestEvent , options) `
145+ ### ` trackPageview(event , options) `
148146
149147Track a pageview on the server.
150148
151149** Parameters:**
152150
153- - ` options ` (object): Additional metadata to track (optional)
151+ - ` event ` (H3Event): Nitro request event
152+ - ` metadata ` (object): Additional metadata to track (optional)
154153
155- ### ` trackEvent(requestEvent , eventName, options) `
154+ ### ` trackEvent(event , eventName, options) `
156155
157156Track a custom event on the server.
158157
159158** Parameters:**
160159
161- - ` options ` (object):
162- - ` hostname ` (string): Your Simple Analytics hostname
163- - ` metadata ` (object): Additional metadata to track
164- - ` ignoreMetrics ` (object): Metrics to ignore for this pageview
165- - ` collectDnt ` (boolean): Whether to collect data when DNT is enabled
166- - ` strictUtm ` (boolean): Whether to use strict UTM parameter parsing
167-
168- ## Migration to v2.0
169-
170- ## Do Not Track (DNT)
171-
172- ### Client-side analytics
173-
174- ### Server-side analytics
175-
176- ## Ignoring metrics To also record DNT visitors you can add data-collect-dnt="true" to the script tag
160+ - ` event ` (H3Event): Nitro request event
161+ - ` eventName ` (string): Name of the event to track
162+ - ` metadata ` (object): Additional metadata to track (optional)
177163
178164## License
179165
0 commit comments