Basic Usage
Lifecycle
Engagement
Use Cases
Why Use PageTracker?
PageTracker is the primary tracking method because it:- Integrates with standard events - Works seamlessly with Permutive’s event schema
- Tracks engagement automatically - Measures time spent and scroll depth
- Enables contextual cohorts - Supports content-based targeting when URLs are provided
- Provides better insights - Delivers richer data to the Permutive platform
- Associates related events - Groups events with page context
Basic Usage
Creating a PageTracker
A PageTracker object should be created when the user starts viewing a page/screen, and closed when viewing finishes.Lifecycle Management
When to Create
Create the PageTracker inonCreate():
When to Pause/Resume
Callpause() and resume() to track engagement time accurately:
When to Close
Always close the PageTracker when done:⚠️ Important: Always Close Failing to close PageTracker can lead to memory leaks and inaccurate engagement metrics.
Tracking Engagement
Tracking Time Spent
PageTracker automatically tracks time spent by usingpause() and resume():
close().
Tracking Scroll Depth
UseupdatePercentageViewed() to track how much content the user has read:
Tracking Additional Events
Track other events associated with the page using PageTracker’strack() methods:
URL Schemes
Web Content
For web content, use full URLs:App Screens
For native app screens, use custom URI schemes:💡 URLs Enable Contextual Cohorts When you provide URLs, Permutive can generate contextual cohorts based on content analysis. This works for publicly accessible web URLs.
Events Generated
PageTracker automatically generates these events:Pageview Event
Tracked when PageTracker is created:PageviewComplete Event
Tracked when PageTracker is closed:PageviewEngagement Events
Periodic engagement events (if configured):Use Cases
News/Content App
News/Content App
E-Commerce Product Page
E-Commerce Product Page
Video App (Non-Video Content)
Video App (Non-Video Content)
For video content itself, use MediaTracker. For video details/description pages:
When to Use PageTracker vs EventTracker
Use PageTracker When:
- ✅ Tracking article/content views
- ✅ Tracking screen views in your app
- ✅ Measuring time spent on a page/screen
- ✅ Tracking scroll depth
- ✅ You want contextual cohorts
- ✅ Events are associated with a page context
Use EventTracker Only When:
- ⚠️ Tracking standalone events (button clicks not tied to pages)
- ⚠️ Tracking background events
- ⚠️ Events have no page context
💡 Default to PageTracker Most customer implementations should primarily use PageTracker. EventTracker is for specific use cases.See Event Tracking for EventTracker documentation.
Troubleshooting
PageTracker Not Tracking Time
PageTracker Not Tracking Time
Problem: Engaged time is always 0.Cause: Not calling
pause() and resume().Solution: Implement lifecycle callbacks:Memory Leaks
Memory Leaks
Problem: App memory usage grows over time.Cause: Not closing PageTracker.Solution: Always close in
onDestroy():Contextual Cohorts Not Working
Contextual Cohorts Not Working
Problem: No contextual cohorts for pages.Causes:
- Feature not enabled
- Not providing URLs
- URLs not publicly accessible
- Contact Customer Success Manager to enable
- Always provide URLs in
trackPage() - Ensure URLs are publicly accessible for web content
Events Not Appearing
Events Not Appearing
Problem: Pageview events not tracked.Solutions:
- Enable debug logging:
permutive.setDeveloperMode(true) - Check logs for “Published events with names (Pageview)”
- Verify event properties match your schema
- See Verification Guide
Best Practices
- Do
- Don't
- Create PageTracker in
onCreate() - Call
pause()inonPause() - Call
resume()inonResume() - Call
close()inonDestroy() - Provide URLs when possible for contextual cohorts
- Track scroll depth for content pages
- Use PageTracker for all page/screen views
Related Documentation
Quick Start Guide
Get started with the SDK
Event Properties
Add structured data to events
Contextual Data
Content-based segmentation
Event Tracking
For standalone events
Video Tracking
For video content
Verification Guide
Verify your integration
API Reference
For complete API documentation, see the Javadocs.PageTracker Interface
pause()- Pause engagement trackingresume()- Resume engagement trackingupdatePercentageViewed(percentage: Float)- Update scroll depthtrack(eventName: String)- Track event with this page contexttrack(eventName: String, properties: EventProperties?)- Track event with propertiesclose()- Complete page tracking and send PageviewComplete event