Quick Start
Video Tracking
iOS SDK Reference
Overview
tvOS applications use the Permutive iOS SDK. The same SDK that powers iOS applications fully supports tvOS 12.0 and later, providing identical APIs for tracking, identity management, and ad targeting.Same SDK, Same APIs: The Permutive iOS SDK supports both iOS and tvOS with a unified codebase. All features documented in the iOS SDK are available on tvOS unless otherwise noted.
Requirements
| Requirement | Version |
|---|---|
| tvOS | 12.0+ |
| Xcode | 13.0+ |
| Swift | 5.0+ |
Installation
- Swift Package Manager
- CocoaPods
Add the package URL in Xcode:Select
Permutive_iOS as the package product.Initialization
Initialize the SDK in your app delegate or app entry point:Video Tracking
Video tracking on tvOS uses the sameMediaTracker API as iOS. This is the primary use case for CTV applications.
Creating a MediaTracker
Integrating with AVPlayer
tvOS applications typically useAVPlayerViewController for video playback:
MediaTracker Lifecycle
| Method | Effect | Events Generated |
|---|---|---|
play() | Starts/resumes playback tracking | VideoPlay (first call) |
pause() | Pauses tracking | VideoPause |
stop() | Ends tracking permanently | VideoComplete |
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
tvOS-Specific Considerations
Focus-Based Navigation
Focus-Based Navigation
No IDFA/ATT on tvOS
No IDFA/ATT on tvOS
Unlike iOS, tvOS does not support IDFA or App Tracking Transparency. Use alternative identifiers:
- User account IDs (hashed)
identifierForVendorfor anonymous tracking- Custom identifiers from your authentication system
Background Playback
Background Playback
tvOS apps may continue video playback in the background. Ensure your MediaTracker handles this:
Top Shelf Extensions
Top Shelf Extensions
If your app has a Top Shelf extension, note that extensions run in a separate process and cannot share the Permutive SDK state with your main app.
Best Practices
- Do
- Don't
- Initialize SDK early in app launch
- Create MediaTracker when video is ready to play
- Call
stop()when video ends or user exits - Sync
play()/pause()with actual player state - Use
identifierForVendoror account IDs for identity - Include video metadata for richer cohorts
Troubleshooting
SDK not initializing
SDK not initializing
Problem: Permutive.shared is nil or initialization fails.Solutions:
- Verify API key and organization ID are correct
- Ensure
configure()is called before accessingshared - Check for initialization errors in the catch block
- Enable debug logging:
options.logModes = LogMode.all
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 network connectivity on the device
Engagement time incorrect
Engagement time incorrect
Problem: Engagement metrics don’t match expected values.Solutions:
- Sync
play()/pause()calls with actual player state - Handle buffering states with
pause() - Provide accurate duration when creating MediaTracker
Related Documentation
iOS SDK Overview
Complete iOS/tvOS SDK documentation
iOS Video Tracking
Detailed MediaTracker documentation
iOS Video Ad Tracking
Video advertisement tracking
CTV Video Best Practices
Cross-platform video tracking guide