Load Privatus Analytics with Cloudflare Zaraz
Load the Privatus Analytics tracker through Cloudflare Zaraz with a Custom HTML tool, handle Zaraz single-page app support and send events from your site.
Zaraz loads third-party tools from Cloudflare's edge. Use a Custom HTML tool to load the Privatus Analytics tracker.
- In the Cloudflare dashboard open your zone and go to Zaraz → Tools configuration → Add new tool → Custom HTML.
- Name it "Privatus Analytics" and paste:
<script defer src="https://privatusstats.com/js/pa.js" data-site="pa_YOURSITEID" data-modules="engage,auto,vitals,clicks,ask"></script>
- Firing trigger: Pageview.
- Save and publish.
The Custom HTML tool puts the script into the page, so it runs in the visitor's browser like the normal snippet. Verify the installation after publishing. If nothing arrives, add the snippet to your pages directly instead.
Single-page apps: the tracker follows history.pushState navigations
itself. If Single Page Application support is on in Zaraz, it fires
Pageview triggers again on route changes, which would load the tracker a
second time and count pages twice. Keep Zaraz's SPA support off, or keep
this tool out of it.
Events#
Call the JavaScript API from other Zaraz tools or from your site with
privatus.track(…). Zaraz's own zaraz.track() doesn't forward to
Privatus Analytics.