Zaraz
Run trackr as a Cloudflare Zaraz tool, without code in the site, forwarding events to a trackr portal.
On a site that uses Cloudflare Zaraz, trackr can run as a Zaraz tool: Zaraz already loads on every page and runs tools on Cloudflare’s servers, so the site needs no script and no tracking route of its own. The tool is a Custom Managed Component that forwards pageviews and events to a trackr portal in forwarding mode, with the visitor’s IP, User-Agent and country, and the site’s forwarding secret.
The component stores nothing in the browser: it sets no cookies and uses neither Zaraz’s client storage nor scripts in the page.
Deploy the component
The component ships with the package as zaraz.js. Deploy it once to the Cloudflare account
of the site’s zone (Wrangler signed in):
npm install @casoon/trackr
npx managed-component-to-cloudflare-worker node_modules/@casoon/trackr/zaraz.js trackr
This creates the Worker custom-mc-trackr. Run it again after updating the package.
Add the tool
In the portal’s admin area, create a forwarding secret for the site and note the site ID. Then, in Zaraz under Tools Configuration → Third-party tools:
- Add new tool → Custom Managed Component, choose
custom-mc-trackr. - Permissions: the component only sends requests from the server. It needs no access to cookies, client storage or page scripts; leave those off.
- Settings:
endpoint: the portal’s collect endpoint, e.g.https://trackr.example.com/api/collectsiteId: the site IDsecret: the forwarding secret
- Default fields: add
countrywith Zaraz’s country of the visitor ({{ system.device.location.country }}). Without it, events carry no country. - Actions: the Pageview action sends pageviews. For custom events, add an action of type
eventwith the trigger of your choice and a fieldnameholding the event name (Zaraz’s Event Name forzaraz.track()calls). Other fields of the action become event props; only text, numbers and true/false values are sent.
Whether the tool gets a consent purpose in Zaraz’s consent management is the site operator’s decision; it reads and stores nothing on the device (Privacy). Other tools on the site may still make Zaraz set cookies.
Single-page sites
On sites that change pages without a full load (Astro’s ClientRouter, React Router), turn
on Single Page Application support in the Zaraz settings, or call zaraz.spaPageview()
after a navigation. Otherwise only the first page of a visit is counted.
Differences to the script
- Engagement time: the tool cannot tell when a page is hidden, so it sends no visible seconds. Sessions count as engaged only with two or more pageviews or a custom event, and the average engagement time stays at zero for these sites.
- Query strings: with Zaraz’s privacy setting Remove URL query parameters on, pages arrive without their query, and UTM parameters are lost with it.
- Zaraz events: every pageview and event is a Zaraz event and counts toward the account’s Zaraz event allowance.