Skip to main content
The AdTracker API allows you to track video advertisement events. Use this to measure ad views, engagement, clicks, and completions within video content.
Android is the only Permutive SDK with a native ad tracker. iOS / tvOS and Web CTV publishers emit ad events manually via track(...). The typed AdTracker lifecycle below is unique to Android — use it instead of generic track() calls so the emitted events match the canonical schema automatically.

Creating AdTracker

Ad Methods

Use Cases

Interactions

Overview

AdTracker provides comprehensive video ad tracking:
  • Automatic lifecycle tracking - Tracks VideoAdView and VideoAdCompletion events
  • Engagement metrics - Measures time spent watching ads
  • Click tracking - Tracks ad interactions
  • Custom events - Track custom ad-related events
  • Shared context - Can share View ID with parent MediaTracker

Creating an AdTracker

AdTracker can be created in two ways: Use this when the ad is related to video content currently being viewed. The AdTracker will share the same View ID with the MediaTracker:

2. Standalone AdTracker

Use this for standalone video ads not associated with specific video content:

Ad Events

AdTracker automatically generates these events:

1. VideoAdView Event

Tracked when AdTracker is created:

2. VideoAdCompletion Event

Tracked when completion() is called:

3. VideoAdClicked Event

Tracked when clicked() is called:

AdTracker Methods

play()

Call when the ad starts playing. AdTracker initializes in a paused state, so call this immediately if the ad auto-plays:

play(positionMs)

Call when playback position changes (e.g., seeking):

pause()

Call when the ad is paused or buffering:

clicked()

Call when the user clicks on the ad. This tracks a VideoAdClicked event:

completion()

Call when the ad is no longer being shown. This tracks a VideoAdCompletion event with engagement properties:
⚠️ Important Once completion() is called, the AdTracker is closed and subsequent method calls will have no effect.

Custom Events

Track custom ad-related events:

Ad Properties

Standard Ad Properties

Property Reference

All properties are passed to every event tracked through the AdTracker.

Complete Example

Kotlin - Pre-Roll Ad

Java - Pre-Roll Ad


Use Cases

Ad shown before video content starts:

Tracking Ad Interactions

Click Tracking

Skip Tracking

The canonical schema defines VideoAdView, VideoAdEngagement, VideoAdCompletion, and VideoAdClicked — there is no standard “skipped” event. If you want to capture skips, emit a custom event via trackWithAdProperties(...) and add the event name to your workspace schema:

Error Tracking

Errors are likewise not in the standard schema — emit a custom event if you need to capture ad-load failures:

Troubleshooting

Problem: VideoAdCompletion events not appearing.Cause: completion() not called.Solution: Always call completion() when ad finishes:
Problem: Ad events have same View ID as video.Cause: This is expected when creating AdTracker from MediaTracker.This is correct behavior - it links ad to video content. For independent tracking, use standalone AdTracker:
Problem: Engaged time is wrong.Causes:
  1. Not calling play() when ad starts
  2. Not calling pause() for buffering
Solution: Track all state changes:
Problem: Multiple VideoAdCompletion events tracked.Cause: Calling completion() multiple times.Solution: Call completion() only once. After calling it, AdTracker is closed.See Common Errors for more troubleshooting.

Best Practices

  • Always call completion() when ad finishes
  • Track play/pause accurately
  • Use clicked() for click tracking
  • Create from MediaTracker for in-content ads
  • Provide campaign and creative IDs
  • Call play() immediately if ad auto-plays

Video Tracking

Track video content

Event Properties

Custom properties

Page Tracking

Track pages

Issues

Solve common issues

API Reference

For complete API documentation, see the Javadocs.

AdTracker Interface

  • play() - Start/resume ad playback
  • play(positionMs: Long) - Start at specific position
  • pause() - Pause ad playback
  • clicked() - Track ad click (sends VideoAdClicked event)
  • completion() - Complete ad tracking (sends VideoAdCompletion event)
  • trackWithAdProperties(eventName: String) - Track custom event with ad properties
  • trackWithAdProperties(eventName: String, customProperties: EventProperties) - Track custom event with ad and custom properties

Creating AdTracker

  • MediaTracker.trackAdView(durationMs: Long, adProperties: AdTracker.AdProperties?) - Create from MediaTracker (shares View ID)
  • Permutive.trackVideoAdView(durationMs: Long, adProperties: AdTracker.AdProperties?, pageProperties: MediaTracker.PageProperties?, customEventProperties: EventProperties? = null) - Create standalone AdTracker

AdProperties

  • AdTracker.AdProperties(title, durationInSeconds, isMuted, campaignId, creativeId) - Ad property container