AxiTrace Page View event - parameters, required fields, and integration examples.

Page View Event

Track when users view pages on your website. Page views are fundamental for understanding user navigation, measuring content engagement, and attributing marketing campaigns.

POST /v1/page/view
Automatic Page View Tracking

The JavaScript SDK automatically tracks page views by default. If you're using server-side tracking in addition to the SDK, you must disable automatic tracking to avoid duplicate events.

Forwarding page views to GA4? Watch for double-counting

Unlike Facebook and TikTok - which deduplicate the browser pixel and the server-side (CAPI) event using a shared event ID - Google Analytics 4 does not deduplicate a server-side Measurement Protocol event against your client-side Google tag. So if your site already runs Google Analytics client-side (gtag.js or Google Tag Manager) and you also enable page.view forwarding on your AxiTrace GA4 connection, every page view is counted twice in GA4. The same applies to the other overlapping events (Product View, Add to Cart, Search).

Recommendation: in your AxiTrace GA4 connection, enable only the events GA4 is not already collecting client-side. If your Google tag / GTM covers the funnel, leave those events off and enable just Transaction as a reliable server-side backup (it survives ad-blockers and consent loss). The GA4 connection screen flags each high-duplication-risk event for you.

SDK Automatic Tracking

By default, the JavaScript SDK automatically sends a page.view event when the page loads. This is controlled by the autoTrackPageViews option (default: true).

What the SDK Auto-Collects

When auto-tracking is enabled, the SDK automatically includes the following in every page.view event - you do not need to add these manually:

Data Source
url window.location.href
title document.title
referrer External referrer (persisted across internal navigations via sessionStorage)
screenResolution screen.width x screen.height (e.g., 1920x1080)
navigationType load, pushState, replaceState, popstate, or hashchange
UTM parameters Extracted from URL: utm_source, utm_medium, utm_campaign, utm_term, utm_content, utm_id
Click IDs Extracted from URL and cookies: fbclid, gclid, gbraid, wbraid, ttclid, msclkid, twclid, epik, li_fat_id, sccid, rdt_cid
Ad platform cookies _fbp (Facebook Browser ID), _fbc (Facebook Click Cookie), _ttp (TikTok Browser ID), _ga (Google Analytics Client ID)
Country detection detectedTimezone, detectedLanguage (browser Intl APIs); the country is derived server-side from the IANA timezone and omitted when the timezone is unknown - it is never guessed from the browser language
Visitor/session identity client.customId, client.uuid, sessionId (from SDK cookies)

Disable Automatic Page Views

If you want to track page views from your server instead, disable automatic tracking in the SDK:

<!-- Load SDK synchronously (recommended) -->
<script src="https://axi.yourdomain.com/axitrack.js"></script>
<script>
Axitrace.init({
    apiUrl: 'https://axi.yourdomain.com',
    publicKey: 'pk_live_YOUR_PUBLIC_KEY',
    workspaceId: 'VT-XXXXXXXXXXXXXXXXXXXX',
    autoTrackPageViews: false  // Disable automatic page view tracking
});
</script>
Avoid Duplicate Events

If you track page views from both the JavaScript SDK and your server, you will get duplicate events. Choose one method:

  • Client-side only (recommended for most websites) - Use SDK with autoTrackPageViews: true (default)
  • Server-side only - Disable SDK auto-tracking and send events from your backend
  • Hybrid - Use SDK for browser tracking, server for specific pages (e.g., email opens)

Request Parameters

Required Fields

Field Type Description
label string Human-readable label for the event. Required for server-side /v1/page/view calls. The SDK auto-fills this from the page title.
client object User identification object. Must contain at least one identifier.
params.url string The full URL of the page being viewed. Must start with http:// or https://. The SDK auto-fills this from window.location.href.

Client Object

The client object identifies the user. At least one of these fields is required:

Field Type Description
customId string Your custom user identifier (e.g., database user ID)
uuid string Anonymous device/browser identifier (auto-generated by SDK)
email string User's email address
phone string User's phone number (used for Facebook CAPI and TikTok user matching)
id integer Numeric user ID
Critical: Match SDK User Identifiers

For server-side events, you must pass the same user identifiers that the JavaScript SDK generates. The SDK stores these in cookies:

  • vt_vid - Visitor ID (persistent anonymous identifier)
  • vt_sid - Session ID (current browsing session)
  • vt_uid - User ID (set via Axitrace._instance.identify())

Read these cookies and pass them in your server-side events to properly link all events to the same user profile. See the User Identification guide for complete details.

Optional Fields

Field Type Description
sessionId string Session identifier for grouping events within a user session
time ISO 8601 Event timestamp. If not provided or in the future, server time is used
eventSalt string Unique event ID used for pixel-CAPI deduplication. The SDK auto-generates this for every event. For server-side calls, provide your own UUID to match a pixel event.

Page Parameters (params object)

Field Type Required Description
url string Required Full page URL (e.g., https://example.com/products/widget). Auto-filled by SDK.
title string Optional Page title (document.title). Auto-filled by SDK.
referrer string Optional Referring URL. Auto-filled by SDK with smart external referrer detection. Falls back to HTTP Referer header on server-side.
screenResolution string Optional Screen resolution (e.g., 1920x1080). Auto-filled by SDK for page.view events.
navigationType string Optional How the page was loaded: load (initial), pushState, replaceState, popstate, or hashchange (SPA navigations). Auto-filled by SDK.
path string Optional URL path without domain (e.g., /products/widget)
search string Optional Query string (e.g., ?category=electronics)
hash string Optional URL hash/fragment (e.g., #section-2)

Marketing Attribution Parameters

Page view events are critical for marketing attribution as they capture the first touch with your website. The following tracking parameters are automatically extracted by the SDK from the URL and browser cookies, and stored by the server:

UTM Parameters

Parameter Description Example
utm_source Traffic source google, facebook, newsletter
utm_medium Marketing medium cpc, email, social
utm_campaign Campaign name summer_sale, product_launch
utm_term Paid search keywords running shoes
utm_content Content variant (A/B testing) header_banner, sidebar_ad
utm_id Campaign ID abc123

Advertising Platform Click IDs

Platform Parameters Description
Facebook/Meta fbclid, fbp, fbc Facebook Click ID (from URL), Browser ID and Click Cookie (from _fbp/_fbc cookies)
Facebook Ads campaign_id, adset_id, ad_id Facebook dynamic URL parameters for CAPI attribution
Google Ads gclid, gbraid, wbraid Google Click ID and privacy-safe alternatives. Persisted in cookies for 90 days.
Google Analytics _ga, ga_client_id GA Client ID (from _ga cookie) for cross-platform matching
TikTok ttclid, ttp TikTok Click ID (from URL) and Browser ID (from _ttp cookie)
Microsoft/Bing msclkid Microsoft Advertising Click ID
Twitter/X twclid Twitter Click ID
Pinterest epik Pinterest Click ID
LinkedIn li_fat_id LinkedIn First-Party Ad Tracking ID
Snapchat sccid Snapchat Click ID
Reddit rdt_cid Reddit Click ID
First Touch Attribution

When tracking parameters (UTM, click IDs, or ad platform cookies) are present in a page view event, AxiTrace automatically marks it as a first touch event with is_first_touch: true. This is used to attribute conversions back to the original marketing campaign that brought the user to your site.

Server-Enriched Fields

The following fields are automatically added by the server:

Field Description
ip Client IP address (extracted from X-Forwarded-For, CF-Connecting-IP, X-Real-IP, etc.)
userAgent Browser User-Agent string
timestamp Server timestamp (ISO 8601 format)
is_first_touch Set to true if any tracking parameters (UTM, click IDs, ad cookies) are present

Examples

JavaScript SDK (Manual Tracking)

If you've disabled automatic tracking, you can manually trigger page views using the dedicated trackPageView() method. This method automatically includes the current URL and page title:

// Simplest: trackPageView() auto-fills url and title
Axitrace._instance.trackPageView();

// With extra custom properties
Axitrace._instance.trackPageView({
    category: 'product_page',
    product_id: 'WIDGET-001'
});

// Alternative: using track() directly gives full control over all fields
Axitrace._instance.track('page.view', {
    url: window.location.href,
    title: document.title,
    referrer: document.referrer,
    category: 'product_page'
});
trackPageView() vs track('page.view')

Axitrace._instance.trackPageView(extra) is a convenience method that calls track('page.view', ...) under the hood, automatically merging the current url and title. Use trackPageView() for simplicity, or track('page.view', {...}) when you need full control over all fields.

Server-Side (cURL)

# Note: Replace client identifiers with values from SDK cookies (vt_vid, vt_sid, vt_uid)
curl -X POST https://stat.axitrace.com/v1/page/view \
  -u "sk_live_YOUR_SECRET_KEY:" \
  -H "Content-Type: application/json" \
  -H "User-Agent: MyApp/1.0" \
  -d '{
    "label": "Product Page View",
    "client": {
        "customId": "value-from-vt_uid-or-vt_vid-cookie",
        "uuid": "value-from-vt_vid-cookie"
    },
    "sessionId": "value-from-vt_sid-cookie",
    "params": {
        "url": "https://example.com/products/widget",
        "title": "Premium Widget - Example Store",
        "referrer": "https://google.com/search?q=widgets",
        "utm_source": "google",
        "utm_medium": "cpc",
        "utm_campaign": "spring_sale",
        "gclid": "EAIaIQobChMI..."
    }
  }'

Server-Side (PHP)

<?php
$secretKey = getenv('AXITRACE_SECRET_KEY');

// Read AxiTrace SDK cookies - CRITICAL for user profile linking
$visitorId = $_COOKIE['vt_vid'] ?? null;  // Persistent visitor ID
$sessionId = $_COOKIE['vt_sid'] ?? null;  // Current session ID
$userId = $_COOKIE['vt_uid'] ?? null;     // Authenticated user ID (if identified)

$data = [
    'label' => 'Product Page View',
    'client' => [
        // Use userId if available, otherwise fall back to visitorId
        'customId' => $userId ?? $visitorId,
        // Always include the visitor UUID for profile linking
        'uuid' => $visitorId,
    ],
    // Pass the session ID for session-based analytics
    'sessionId' => $sessionId,
    'params' => [
        'url' => (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
        'title' => 'Premium Widget - Example Store',
        'referrer' => $_SERVER['HTTP_REFERER'] ?? '',
        // Pass through any UTM parameters
        'utm_source' => $_GET['utm_source'] ?? null,
        'utm_medium' => $_GET['utm_medium'] ?? null,
        'utm_campaign' => $_GET['utm_campaign'] ?? null,
        'gclid' => $_GET['gclid'] ?? null,
        'fbclid' => $_GET['fbclid'] ?? null
    ]
];

// Remove null values
$data['params'] = array_filter($data['params'], fn($v) => $v !== null);
$data['client'] = array_filter($data['client'], fn($v) => $v !== null);

$ch = curl_init('https://stat.axitrace.com/v1/page/view');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_USERPWD => $secretKey . ':',
    CURLOPT_HTTPHEADER => [
        'Content-Type: application/json',
        'User-Agent: MyApp/1.0'
    ],
    CURLOPT_POSTFIELDS => json_encode($data)
]);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

if ($httpCode === 200) {
    $result = json_decode($response, true);
    // Event tracked successfully
}

Server-Side (Python)

import os
import requests
from flask import request  # Example using Flask

secret_key = os.environ.get('AXITRACE_SECRET_KEY')

# Read AxiTrace SDK cookies - CRITICAL for user profile linking
visitor_id = request.cookies.get('vt_vid')  # Persistent visitor ID
session_id = request.cookies.get('vt_sid')  # Current session ID
user_id = request.cookies.get('vt_uid')     # Authenticated user ID (if identified)

response = requests.post(
    'https://stat.axitrace.com/v1/page/view',
    auth=(secret_key, ''),
    headers={
        'Content-Type': 'application/json',
        'User-Agent': 'MyApp/1.0'
    },
    json={
        'label': 'Product Page View',
        'client': {
            # Use user_id if available, otherwise fall back to visitor_id
            'customId': user_id or visitor_id,
            # Always include the visitor UUID for profile linking
            'uuid': visitor_id,
        },
        # Pass the session ID for session-based analytics
        'sessionId': session_id,
        'params': {
            'url': 'https://example.com/products/widget',
            'title': 'Premium Widget - Example Store',
            'referrer': 'https://google.com',
            'utm_source': request.args.get('utm_source'),
            'utm_medium': request.args.get('utm_medium'),
            'utm_campaign': request.args.get('utm_campaign')
        }
    }
)

if response.status_code == 200:
    result = response.json()
    print(f"Event tracked: {result['eventId']}")

Response

Success Response (200 OK)

{
    "success": true,
    "eventId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "action": "page.view"
}

Error Responses

Status Error Description
400 label is required The label field is missing (server-side /v1/page/view only; SDK auto-fills this)
400 params.url is required for page.view event The URL parameter is missing from params
400 params.url must be a valid URL starting with http:// or https:// URL doesn't start with http:// or https://
400 client must have at least one identifier (customId, id, uuid, or email) No user identifier provided in the client object
401 unauthorized Invalid or missing API key

Pixel-CAPI Deduplication

The SDK automatically handles deduplication between browser pixels (Facebook Pixel, TikTok Pixel) and server-side Conversions API (CAPI). For every page.view event, the SDK:

  1. Generates a unique eventSalt (UUID)
  2. Calls fbq('track', 'PageView', data, {eventID: eventSalt}) if Facebook Pixel is present
  3. Calls ttq.track('Pageview', data, {event_id: eventSalt}) if TikTok Pixel is present
  4. Sends the event to the AxiTrace server with the same eventSalt
  5. The server forwards the event to Facebook CAPI / TikTok Events API with the same event ID
  6. Meta/TikTok matches the pixel and CAPI events by event ID and counts them once
No Manual Deduplication Needed

When using the JavaScript SDK, deduplication is fully automatic. You do not need to generate event IDs or pass eventSalt manually. The SDK handles the entire pixel-CAPI matching flow.

For server-side only tracking (without the SDK), provide your own eventSalt UUID if you also fire the pixel manually and need to deduplicate.

Single Page Applications (SPA)

The AxiTrace SDK automatically detects SPA navigations and fires page.view events when the URL changes. It hooks into:

  • history.pushState() - used by React Router, Vue Router, etc.
  • history.replaceState() - silent URL updates
  • popstate event - browser back/forward buttons
  • hashchange event - hash-based routing (e.g., Angular)

Each auto-tracked SPA page view includes a navigationType field indicating how the navigation occurred (e.g., pushState, popstate). The SDK also deduplicates navigations to the same URL, so repeated pushState calls to the same path won't generate duplicate events.

No Additional Code Needed for SPAs

If autoTrackPageViews is enabled (default), the SDK automatically tracks all SPA route changes. No React hooks, Vue router guards, or manual tracking code is required.

Custom SPA Tracking (Optional)

If you've disabled auto-tracking or need to pass custom properties on SPA navigations:

// React with React Router (only if autoTrackPageViews is disabled)
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';

function usePageTracking() {
    const location = useLocation();

    useEffect(() => {
        Axitrace._instance.trackPageView({
            path: location.pathname,
            search: location.search
        });
    }, [location]);
}

// Vue Router (only if autoTrackPageViews is disabled)
router.afterEach((to, from) => {
    Axitrace._instance.trackPageView({
        path: to.path
    });
});

Best Practices

  • Use SDK auto-tracking - For most websites, the default autoTrackPageViews: true is all you need. The SDK handles URL, title, referrer, attribution, and SPA navigations automatically.
  • Don't manually fire pixel events - Remove fbq('track', 'PageView') and ttq.page() from your code. The SDK calls these automatically with proper deduplication event IDs.
  • Pass through all UTM parameters (server-side) - Don't filter them; AxiTrace will extract what's needed
  • Use consistent user identifiers - Match the same customId across all events
  • Include session IDs (server-side) - Read vt_sid cookie and pass it for session-based analytics
  • Avoid duplicate tracking - Choose either SDK auto-tracking OR server-side, not both