Quick Start
Video Tracking
Android SDK Reference
Overview
Android TV and Google TV applications use the Permutive Android SDK. The same SDK that powers mobile Android applications fully supports Android TV, providing identical APIs for tracking, identity management, and ad targeting.Same SDK, Same APIs: The Permutive Android SDK works seamlessly on Android TV. All features documented in the Android SDK are available on Android TV.
Requirements
Installation
Add the Permutive SDK to yourbuild.gradle:
Initialization
Initialize the SDK in your Application class:Video Tracking
Video tracking on Android TV uses theMediaTracker API. This is the primary use case for CTV applications.
Creating a MediaTracker
Integrating with ExoPlayer
Android TV applications typically use ExoPlayer (now part of Media3) for video playback:MediaTracker Lifecycle
For complete MediaTracker documentation, see Android Video Tracking.
Video Properties
The SDK provides standard video properties for consistent tracking:Video Ad Tracking
Track video advertisements within your content:Identity Management
Set user identities for cross-device tracking:Cohorts and Targeting
Accessing Cohorts
Google Ad Manager Integration
Android TV-Specific Considerations
Leanback UI
Leanback UI
Android TV uses the Leanback library for its 10-foot UI. Ensure your tracking implementation doesn’t interfere with Leanback components:
Picture-in-Picture
Picture-in-Picture
If your app supports PiP mode, continue tracking during PiP:
Android Advertising ID
Android Advertising ID
Android TV supports AAID. Use the AAID provider for automatic advertising ID tracking:See AAID Provider for details.
Background Playback
Background Playback
Android TV apps may continue video playback when the home button is pressed. Handle this appropriately:
Best Practices
- Do
- Don't
- Initialize SDK early in Application.onCreate()
- Create MediaTracker when video is ready to play
- Call
stop()when video ends or user exits - Sync
play()/pause()with actual player state - Handle buffering states with
pause() - Include video metadata for richer cohorts
- Use Leanback-compatible patterns
Troubleshooting
SDK not initializing
SDK not initializing
Problem: Permutive instance is null or initialization fails.Solutions:
- Verify API key and workspace ID are correct
- Ensure initialization happens in Application.onCreate()
- Check for initialization errors in Logcat
- Enable debug mode:
permutive.setDeveloperMode(true)
Events not appearing in dashboard
Events not appearing in dashboard
Problem: Video events don’t show in Permutive dashboard.Solutions:
- Verify MediaTracker was created successfully
- Ensure
play()is called when video starts - Ensure
stop()is called when video ends - Wait 5-10 minutes for events to process
- Check Logcat for “Accepted: 1 / 1” messages
Engagement time incorrect
Engagement time incorrect
Problem: Engagement metrics don’t match expected values.Solutions:
- Sync
play()/pause()calls with actual player state - Call
pause()during buffering - Provide accurate duration when creating MediaTracker
VideoCompletion not tracked
VideoCompletion not tracked
Problem: VideoCompletion events not appearing.Solutions:
- Ensure
stop()is called inonDestroy() - Handle back button to call
stop()before navigation - Verify app isn’t killed before event sends
Related Documentation
Android SDK Overview
Complete Android SDK documentation
Android Video Tracking
Detailed MediaTracker documentation
Android Video Ad Tracking
Video advertisement tracking
CTV Video Best Practices
Cross-platform video tracking guide