@@ -14,13 +14,13 @@ Add the module to your `nuxt.config.ts`:
1414
1515``` ts
1616export default defineNuxtConfig ({
17- modules: [' @simpleanalytics/nuxt' ],
17+ modules: [" @simpleanalytics/nuxt" ],
1818 simpleAnalytics: {
19- hostname: ' your-domain.com' ,
19+ hostname: " your-domain.com" ,
2020 enabled: true ,
21- proxy: true
22- }
23- })
21+ proxy: true ,
22+ },
23+ });
2424```
2525
2626## Usage
@@ -34,11 +34,11 @@ Track pageviews automatically on the server:
3434// This will run on the server and track the pageview
3535if (import.meta.server) {
3636 await trackPageview({
37- hostname: ' your-domain.com' ,
37+ hostname: " your-domain.com" ,
3838 metadata: {
39- source: ' homepage' ,
40- }
41- })
39+ source: " homepage" ,
40+ },
41+ });
4242}
4343</script>
4444```
@@ -50,17 +50,18 @@ Track custom events from API routes or server-side code:
5050``` ts
5151// In a server API route
5252export default defineEventHandler (async (event ) => {
53- await trackEvent (' user_signup' , {
53+ await trackEvent (" user_signup" , {
5454 event ,
5555 metadata: {
56- source: ' registration_form' ,
57- user_type: ' new'
58- }
59- })
60-
61- return { success: true }
62- })
56+ source: " registration_form" ,
57+ user_type: " new" ,
58+ },
59+ });
60+
61+ return { success: true };
62+ });
6363```
64+
6465## Configuration
6566
6667### Module Options
@@ -69,23 +70,23 @@ export default defineEventHandler(async (event) => {
6970export default defineNuxtConfig ({
7071 simpleAnalytics: {
7172 // Your Simple Analytics hostname
72- hostname: ' your-domain.com' ,
73-
73+ hostname: " your-domain.com" ,
74+
7475 // Enable/disable the module
7576 enabled: true ,
76-
77+
7778 // Enable/disable proxy
7879 proxy: true ,
79-
80+
8081 // Auto-collect events
8182 autoCollect: true ,
82-
83+
8384 // Collect data even when DNT is enabled
8485 collectDnt: false ,
85-
86+
8687 // Dashboard mode
87- mode: ' dash' ,
88-
88+ mode: " dash" ,
89+
8990 // Ignore specific metrics
9091 ignoreMetrics: {
9192 referrer: false ,
@@ -97,22 +98,22 @@ export default defineNuxtConfig({
9798 useragent: false ,
9899 screensize: false ,
99100 viewportsize: false ,
100- language: false
101+ language: false ,
101102 },
102-
103+
103104 // Ignore specific pages
104- ignorePages: [' /admin' , ' /private' ],
105-
105+ ignorePages: [" /admin" , " /private" ],
106+
106107 // Allow specific URL parameters
107- allowParams: [' ref' , ' source' ],
108-
108+ allowParams: [" ref" , " source" ],
109+
109110 // Non-unique parameters
110- nonUniqueParams: [' utm_source' ],
111-
111+ nonUniqueParams: [" utm_source" ],
112+
112113 // Strict UTM parameter parsing
113- strictUtm: true
114- }
115- })
114+ strictUtm: true ,
115+ },
116+ });
116117```
117118
118119### Environment Variables
@@ -129,6 +130,7 @@ SIMPLE_ANALYTICS_HOSTNAME=your-domain.com
129130Track a pageview on the server.
130131
131132** Parameters:**
133+
132134- ` options ` (object):
133135 - ` hostname ` (string): Your Simple Analytics hostname
134136 - ` metadata ` (object): Additional metadata to track
@@ -141,6 +143,7 @@ Track a pageview on the server.
141143Track a custom event on the server.
142144
143145** Parameters:**
146+
144147- ` eventName ` (string): Name of the event to track
145148- ` options ` (object):
146149 - ` headers ` (Headers): Request headers
@@ -154,14 +157,12 @@ Track a custom event on the server.
154157MIT License - see the [ LICENSE] ( LICENSE ) file for details.
155158
156159<!-- Badges -->
160+
157161[ npm-version-src ] : https://img.shields.io/npm/v/@simpleanalytics/nuxt/latest.svg?style=flat&colorA=020420&colorB=00DC82
158162[ npm-version-href ] : https://npmjs.com/package/@simpleanalytics/nuxt
159-
160163[ npm-downloads-src ] : https://img.shields.io/npm/dm/@simpleanalytics/nuxt.svg?style=flat&colorA=020420&colorB=00DC82
161164[ npm-downloads-href ] : https://npm.chart.dev/@simpleanalytics/nuxt
162-
163165[ license-src ] : https://img.shields.io/npm/l/@simpleanalytics/nuxt.svg?style=flat&colorA=020420&colorB=00DC82
164166[ license-href ] : https://npmjs.com/package/@simpleanalytics/nuxt
165-
166167[ nuxt-src ] : https://img.shields.io/badge/Nuxt-020420?logo=nuxt.js
167168[ nuxt-href ] : https://nuxt.com
0 commit comments