blog.json to the script as a data-* attribute, so you can add custom properties or proxy the script and events through your own domain without writing a custom script.
With the c15t cookie banner on, OneDollarStats loads through c15t instead, only after a visitor allows the measurement category, and keeps every option below.
1
Add your domain to OneDollarStats
In OneDollarStats, add the domain your visitors use, like
blog.acme.com. OneDollarStats has no site ID or API key and assigns events to a site by its domain.2
Add it to Notra
Open Studio → Sites, select your site, open Integrations and click Add OneDollarStats. Enter the same domain under Domain without
https://. When you click Save, Notra opens a pull request with the change. To configure it in your repository instead, add it to blog.json:blog.json
3
Merge and verify
After you merge the change and the production deployment finishes, visit your live site in a normal browser window and check the dashboard in OneDollarStats. The script ignores visits from headless and automated browsers, so a page loaded by a testing tool never shows up.
Options
The dashboard covers the domain. You set every other option inblog.json, and editing the integration in the dashboard keeps those options as they are.
Notra adds the origin of
scriptUrl to script-src and the origin of collectorUrl to connect-src in the Content-Security-Policy. The script sends most events as an image request and falls back to sendBeacon when that fails.
OneDollarStats reports the path of each page but drops the query string, except for the utm_campaign, utm_source, utm_medium, utm_term and utm_content parameters, which it reports as campaign data.
Custom events
To track clicks in your own components and MDX, adddata-s-event to a link or button. OneDollarStats then sends an event with that name when a visitor clicks it and reads properties from data-s-event-props as name=value pairs separated by ;:
window.stonks.event("Pricing clicked", { placement: "changelog-footer" }). To add properties to the page view of a single page, add a data-s-view-props attribute to any element on it.