@@ -6,7 +6,7 @@ permalink: /install-simple-analytics-with-nuxt
66last_modified_at : 2025-10-24
77---
88
9- This Nuxt module provides a simple way to add privacy-friendly pageview and event tracking using Simple Analytics to your Nuxt 3 or 4 application .
9+ Easily add privacy-friendly pageview and event tracking to your Nuxt 3 or 4 app with the Simple Analytics Nuxt module .
1010
1111## Installation
1212
@@ -16,25 +16,25 @@ npm i @simpleanalytics/nuxt
1616
1717## Environment Variables
1818
19- Set your website domain (as added in your [ Simple Analytics dashboard] ( https://dashboard.simpleanalytics.com/ ) ):
19+ Set your website domain (the same as in your [ Simple Analytics dashboard] ( https://dashboard.simpleanalytics.com/ ) ):
2020
2121``` bash
2222SIMPLE_ANALYTICS_HOSTNAME=example.com
2323```
2424
25- > Omit ` www. ` , just the root domain or if you use a subdomain, include that. Like ` sub.example.com ` .
25+ > Omit ` www. ` Use only the root domain, or include the subdomain if applicable, like ` sub.example.com ` .
2626
2727## Configuration
2828
29- Add the module to your ` nuxt.config.ts ` and optionally set your hostname:
29+ Add the module to your ` nuxt.config.ts ` and optionally define your hostname:
3030
3131``` ts
3232// nuxt.config.ts
3333export default defineNuxtConfig ({
3434 // ...
3535 modules: [" @simpleanalytics/nuxt" ],
3636 simpleAnalytics: {
37- // hostname: "example.com", // optional, if you don't use SIMPLE_ANALYTICS_HOSTNAME
37+ // hostname: "example.com", // optional, uses SIMPLE_ANALYTICS_HOSTNAME if not set
3838 },
3939});
4040```
@@ -43,11 +43,11 @@ export default defineNuxtConfig({
4343
4444### Client-side analytics
4545
46- The module uses the ` simple-analytics-vue ` plugin to auto-inject the Simple Analytics script .
46+ The module automatically injects the Simple Analytics script through the ` simple-analytics-vue ` plugin.
4747
4848### Tracking events in client components
4949
50- To track events programmatically, inject the ` saEvent ` function.
50+ To track custom events, use the injected ` saEvent ` function:
5151
5252``` vue
5353<script setup>
@@ -64,7 +64,7 @@ const likeComment = (comment) => {
6464
6565### Server-side tracking (SSR & API)
6666
67- Track page views or events during server side rendering or in API routes:
67+ You can track pageviews and events from the server during SSR or within Nitro API routes.
6868
6969#### In server-rendered pages
7070
@@ -101,7 +101,7 @@ export default defineEventHandler(async (event) => {
101101
102102### ` trackPageview(options) `
103103
104- Track a pageview on the server.
104+ Tracks a pageview on the server.
105105
106106** Parameters:**
107107
@@ -114,7 +114,7 @@ Track a pageview on the server.
114114
115115### ` trackEvent(eventName, options) `
116116
117- Track a custom event on the server.
117+ Tracks a custom event on the server.
118118
119119** Parameters:**
120120
0 commit comments