Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Format

Blue Mousec619ed924d92
diff --git a/docs/content/docs/api/events.mdx b/docs/content/docs/api/events.mdx
index 17d9df7f1..43d27d913 100644
--- a/docs/content/docs/api/events.mdx
+++ b/docs/content/docs/api/events.mdx
@@ -58,19 +58,19 @@ Must be set to `application/json` for all requests.
#### Pageview payload
-| Name | Type | Required | Description |
-| -------- | --------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| `pid` | `string` | `true` | A project ID to record the pageview event for |
-| `tz` | `string` | `false` | Visitor's timezone (used as a backup in case IP geolocation fails). I.e. if it's set to `Europe/Kiev` and IP geolocation fails, we will set the country of this entry to `Ukraine`) |
-| `pg` | `string` | `false` | A page to record the pageview event for (e.g. `/home`). All our scripts send the `pg` string with a slash (`/`) at the beginning, it's not a requirement but it's best to do the same so the data would be consistent when used together with our official scripts |
-| `title` | `string` or `null` | `false` | Page title, up to 2,048 characters. Omit it or send `null` to leave the title unset. |
-| `lc` | `string` | `false` | A locale of the user (e.g. `en-US` or `uk-UA`) |
-| `ref` | `string` | `false` | A referrer URL (e.g. `https://example.com/`) |
-| `so` | `string` | `false` | A source of the pageview (e.g. `ref`, `source` or `utm_source` GET parameter) |
-| `me` | `string` | `false` | A medium of the pageview (e.g. `utm_medium` GET parameter) |
-| `ca` | `string` | `false` | A campaign of the pageview (e.g. `utm_campaign` GET parameter) |
-| `unique` | `boolean` | `false` | If set to true, only unique visits will be saved |
-| `perf` | `object` | `false` | An object with performance metrics related to the page load. See [Performance metrics](#performance-metrics-payload) for more details |
+| Name | Type | Required | Description |
+| -------- | ------------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| `pid` | `string` | `true` | A project ID to record the pageview event for |
+| `tz` | `string` | `false` | Visitor's timezone (used as a backup in case IP geolocation fails). I.e. if it's set to `Europe/Kiev` and IP geolocation fails, we will set the country of this entry to `Ukraine`) |
+| `pg` | `string` | `false` | A page to record the pageview event for (e.g. `/home`). All our scripts send the `pg` string with a slash (`/`) at the beginning, it's not a requirement but it's best to do the same so the data would be consistent when used together with our official scripts |
+| `title` | `string` or `null` | `false` | Page title, up to 2,048 characters. Omit it or send `null` to leave the title unset. |
+| `lc` | `string` | `false` | A locale of the user (e.g. `en-US` or `uk-UA`) |
+| `ref` | `string` | `false` | A referrer URL (e.g. `https://example.com/`) |
+| `so` | `string` | `false` | A source of the pageview (e.g. `ref`, `source` or `utm_source` GET parameter) |
+| `me` | `string` | `false` | A medium of the pageview (e.g. `utm_medium` GET parameter) |
+| `ca` | `string` | `false` | A campaign of the pageview (e.g. `utm_campaign` GET parameter) |
+| `unique` | `boolean` | `false` | If set to true, only unique visits will be saved |
+| `perf` | `object` | `false` | An object with performance metrics related to the page load. See [Performance metrics](#performance-metrics-payload) for more details |
#### Performance metrics payload
diff --git a/docs/content/docs/script-reference.mdx b/docs/content/docs/script-reference.mdx
index feb2c47f2..2ea5b1f10 100644
--- a/docs/content/docs/script-reference.mdx
+++ b/docs/content/docs/script-reference.mdx
@@ -105,13 +105,13 @@ swetrix.trackViews({
});
```
-| Name | Description | Default value |
-| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
-| unique | If true, only unique events will be saved. This param is useful when tracking single-page landing websites. | `false` |
+| Name | Description | Default value |
+| --------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
+| unique | If true, only unique events will be saved. This param is useful when tracking single-page landing websites. | `false` |
| callback | A callback used to edit / prevent sending pageviews.<br />It accepts an object with pageview event data as a parameter which has the following structure: <br />lc: string \| undefined<br />tz: string \| undefined<br />ref: string \| undefined<br />so: string \| undefined<br />me: string \| undefined<br />ca: string \| undefined<br />te: string \| undefined<br />co: string \| undefined<br />qs: string \| undefined<br />meta: object \| undefined ("object" values must be string, number, boolean, null, or undefined)<br />pg: string \| null \| undefined<br />title: string \| null \| undefined<br />profileId: string \| undefined<br /><br />The callback is supposed to return the edited payload or `false` to prevent sending the pageview. If `true` is returned, the payload will be sent as-is. | `undefined` |
-| heartbeatOnBackground | Send Heartbeat requests when the website tab is not active in the browser.<br />Setting this to `true` means users who keep your website open in an inactive browser tab or window can still be counted in realtime statistics.<br />Setting this to true is usually useful for services like Spotify or Youtube. | `false` |
-| hash | Set to `true` to enable hash-based routing for every hash, or provide an array of exact hash values to include. For example, `['pricing', 'features']` includes `/path#pricing` and `/path#features` while ignoring other hashes. A leading `#` is optional in array values. | `false` |
-| search | Set to `true` to enable search-based routing for every query parameter, or provide an array of parameter names to include. For example, `['search', 'page']` includes those parameters while ignoring unrelated ones. You can enable both `hash` and `search`; a pageview is fired only when an included part of the URL changes. | `false` |
+| heartbeatOnBackground | Send Heartbeat requests when the website tab is not active in the browser.<br />Setting this to `true` means users who keep your website open in an inactive browser tab or window can still be counted in realtime statistics.<br />Setting this to true is usually useful for services like Spotify or Youtube. | `false` |
+| hash | Set to `true` to enable hash-based routing for every hash, or provide an array of exact hash values to include. For example, `['pricing', 'features']` includes `/path#pricing` and `/path#features` while ignoring other hashes. A leading `#` is optional in array values. | `false` |
+| search | Set to `true` to enable search-based routing for every query parameter, or provide an array of parameter names to include. For example, `['search', 'page']` includes those parameters while ignoring unrelated ones. You can enable both `hash` and `search`; a pageview is fired only when an included part of the URL changes. | `false` |
The `trackViews` function returns a `Promise` with an object with some methods allowing you to alter the behaviour of page tracking:
@@ -130,7 +130,7 @@ The `trackViews` callback receives the title as `payload.title`. Return a replac
```typescript
swetrix.trackViews({
- callback: (payload) => ({ ...payload, title: 'Product documentation' }),
+ callback: (payload) => ({ ...payload, title: "Product documentation" }),
});
```
@@ -138,7 +138,7 @@ For manual tracking, pass `title` alongside `pg`:
```typescript
swetrix.pageview({
- payload: { pg: '/pricing', title: 'Pricing' },
+ payload: { pg: "/pricing", title: "Pricing" },
});
```