Tracking Script

Complete reference for the JustAnalytics client-side tracking script.

Overview#

The JustAnalytics tracking script (tracker.js) is a lightweight (~3KB gzipped) JavaScript file that automatically collects pageviews, sessions, and user interactions. It requires no cookies and respects user privacy.

Installation#

<script
  defer
  src="https://justanalytics.app/tracker.js"
  data-site-id="YOUR_SITE_ID"
></script>

Configuration#

Configure the tracker using data-* attributes on the script tag:

| Attribute | Type | Default | Description | |-----------|------|---------|-------------| | data-site-id | string | Required | Your unique site identifier | | data-api-url | string | Auto-detected | Override the ingestion API URL | | data-domain | string | Current domain | Override the tracked domain |

Automatic Tracking#

The tracker automatically captures:

Pageviews#

Every page navigation triggers a pageview event. For single-page applications (SPA), the tracker listens for popstate and pushState events to detect route changes.

Session Management#

Sessions are identified using a fingerprint derived from:

  • IP address hash (computed server-side)
  • User agent string
  • Screen resolution
  • Timezone

A session expires after 30 minutes of inactivity.

Referrer Tracking#

The tracker captures and categorizes referrer information:

  • Direct -- no referrer or same-domain
  • Search -- Google, Bing, DuckDuckGo, etc.
  • Social -- Twitter, Facebook, LinkedIn, Reddit, etc.
  • Email -- known email providers
  • Referral -- all other external domains

UTM Parameters#

The tracker automatically extracts UTM parameters from the URL:

  • utm_source
  • utm_medium
  • utm_campaign
  • utm_term
  • utm_content

Privacy Features#

Do Not Track#

When a visitor has DNT (Do Not Track) enabled in their browser, the tracker will not send any data. This is enabled by default and cannot be overridden.

Bot Filtering#

Known bots and crawlers are automatically filtered out based on user agent patterns. This includes search engine crawlers, monitoring services, and known bot signatures.

No Cookies#

The tracker never sets cookies. Session identification is done entirely through server-side fingerprinting, making it fully GDPR compliant without requiring a consent banner.

SPA Support#

For single-page applications built with React, Vue, Angular, or similar frameworks, the tracker automatically detects route changes by monitoring:

  • history.pushState calls
  • history.replaceState calls
  • popstate events

No additional configuration is needed.

Event Payload#

Each event sent to the ingestion API includes:

{
  "siteId": "your_site_id",
  "url": "https://example.com/page",
  "referrer": "https://google.com",
  "title": "Page Title",
  "screenWidth": 1920,
  "screenHeight": 1080,
  "language": "en-US",
  "timezone": "America/New_York",
  "utm": {
    "source": "google",
    "medium": "cpc",
    "campaign": "spring_sale"
  }
}