Skip to main content
PageTracker is the recommended approach for tracking user interactions in your iOS and tvOS apps. It automatically generates Pageview events, measures engagement time, and enables contextual cohorts when URLs are provided.

Lifecycle

Events

Engagement

Overview

PageTracker provides:
  • Automatic Pageview events on first resume
  • Engagement time tracking between resume and pause
  • PageViewComplete events when stopped
  • Contextual cohort generation when URLs are provided
  • Linked event tracking with consistent view IDs
Only one PageTracker (or MediaTracker) can be active at a time. Creating a new tracker automatically stops any existing one.

Creating a PageTracker

PageTracker Lifecycle

State Diagram

Lifecycle Methods

UIViewController Integration

SwiftUI Integration

For SwiftUI, use onAppear and onDisappear modifiers:

Tracking Events

Track additional events linked to the current page view:
Events tracked via PageTracker.track() include the same Context and view ID as the Pageview event, enabling linked analysis.

Engagement Tracking

Scroll Depth

Track how much content users have viewed:

Engagement Time

Engagement time is automatically tracked:
  • Timer starts when resume() is called
  • Timer pauses when pause() is called
  • Total engagement time sent with PageViewComplete event

Context Object

The Context object provides page metadata:
The domain is automatically inferred from the url if set. Always provide URLs to enable contextual cohort generation.

Background Handling

The SDK automatically handles app backgrounding:

tvOS Considerations

tvOS Note: PageTracker works identically on tvOS. Use focus-based navigation events instead of touch-based scrolling for engagement tracking.

Error Handling

Best Practices

  • Create PageTracker in viewDidLoad
  • Call resume() in viewDidAppear
  • Call pause() in viewDidDisappear
  • Call stop() in deinit
  • Always provide URLs for contextual targeting
  • Track meaningful events with descriptive names
  • Update scroll percentage as user scrolls

Troubleshooting

Problem: No Pageview event in logs.Solutions:
  • Ensure resume() is called after creating the PageTracker
  • Check that SDK is initialized before creating PageTracker
  • Verify no errors when creating PageTracker
  • Enable debug logging: options.logModes = LogMode.all
Problem: PageTracker stops when navigating.Cause: Creating a new PageTracker stops any existing one.Solution: This is expected behavior. Only one tracker can be active. Stop the previous tracker explicitly if needed, or let the new one replace it.
Problem: Events tracked via PageTracker are rejected.Solutions:
  • Check event names match your schema
  • Verify property names and types
  • Enable debug logging to see schema errors

Event Tracking

Track custom events

Contextual Data

Content-based targeting

Google Ad Manager

Ad targeting with PageTracker

Event Properties

Structuring event data