Tracking Script

Complete reference for the Zero Trust Analytics tracking script

Script Attributes

The tracking script supports several configuration options via data-* attributes:

<script
  defer
  data-site-id="YOUR_SITE_ID"
  src="https://ztas.io/js/analytics.js">
</script>

Available Attributes

AttributeRequiredDefaultDescription
data-site-idYes-Your unique Site ID
data-auto-trackNotrueAutomatically track page views
data-spaNofalseEnable SPA mode (manual navigation tracking)
data-debugNofalseEnable console debug logging
data-track-scrollNotrueTrack scroll depth (25%, 50%, 75%, 100%)
data-track-outboundNotrueTrack outbound link clicks
data-track-downloadsNotrueTrack file downloads
data-track-formsNotrueTrack form submissions

What Gets Tracked Automatically

When the script loads, it automatically tracks:

  • Page views - Every page load and navigation
  • Session duration - Time spent on your site
  • Bounce rate - Visitors who leave without interaction
  • Referrer - Where visitors came from
  • UTM parameters - Campaign tracking data
  • Device info - Mobile vs desktop, browser, OS
  • Geographic data - Country and region (not IP-based)

What We DON’T Track

  • IP addresses (hashed immediately, never stored)
  • Cookies (we don’t use any)
  • Personal data (names, emails, etc.)
  • Cross-site behavior
  • Fingerprints

Script Size

The tracking script is under 3KB minified and gzipped. It won’t impact your page load performance.

Excluding Pages

Configure page exclusions in your site settings in the dashboard. Go to Sites → Settings → Exclude Paths to add URL patterns that should not be tracked.

Disabling Auto-Tracking

If you want full control over what gets tracked, disable auto-tracking:

<script
  defer
  data-site-id="YOUR_SITE_ID"
  data-auto-track="false"
  src="https://ztas.io/js/analytics.js">
</script>

Then manually call zta.trackPageview() when you want to track a view.

SPA Mode

For single-page applications that handle their own routing:

<script
  defer
  data-site-id="YOUR_SITE_ID"
  data-spa="true"
  src="https://ztas.io/js/analytics.js">
</script>

In SPA mode, call zta.trackPageview() after each route change. See the SPA Support guide for framework-specific examples.