文件
瀏覽文件

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.

以 Markdown 檢視

Zaraz loads third-party tools from Cloudflare's edge. Use a Custom HTML tool to load the Privatus Analytics tracker.

  1. In the Cloudflare dashboard open your zone and go to Zaraz → Tools configuration → Add new tool → Custom HTML.
  2. Name it "Privatus Analytics" and paste:
html
   <script defer src="https://privatusstats.com/js/pa.js" data-site="pa_YOURSITEID" data-modules="engage,auto,vitals,clicks,ask"></script>
  1. Firing trigger: Pageview.
  2. 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.