Skip to content
This repository has been archived by the owner on Nov 26, 2021. It is now read-only.

Commit

Permalink
Add advert play progress percentage to all ad tracking calls, and add…
Browse files Browse the repository at this point in the history
… tracking events for when videos become skippable and if/when they are skipped
  • Loading branch information
rowanbeentje committed Nov 23, 2016
1 parent 17723de commit 456bc51
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/js/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ class VideoAds {
this.adsManager.addEventListener(google.ima.AdEvent.Type.LOADED, this.adEventHandler);
this.adsManager.addEventListener(google.ima.AdEvent.Type.STARTED, this.adEventHandler);
this.adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE, this.adEventHandler);
this.adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPED, this.adEventHandler);
this.adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPABLE_STATE_CHANGED, this.adEventHandler);

this.adsLoaded = true;
this.startAds();
Expand Down Expand Up @@ -247,7 +249,8 @@ class VideoAds {
progress: 0,
adDuration: ad.getDuration(),
adMinDuration: ad.getMinSuggestedDuration(),
adTitle: ad.getTitle()
adTitle: ad.getTitle(),
adProgress: this.video.getProgress()
},
bubbles: true
};
Expand Down Expand Up @@ -288,6 +291,18 @@ class VideoAds {
// Would be used to clear the interval
}
break;

// Add tracking for when an advert becomes skippable, and whether it's skipped
case google.ima.AdEvent.Type.SKIPPABLE_STATE_CHANGED:
options.detail.action = 'adSkippable';
const skippableEvent = new CustomEvent('oTracking.event', options);
document.body.dispatchEvent(skippableEvent);
break;
case google.ima.AdEvent.Type.SKIPPED:
options.detail.action = 'adSkip';
const skipEvent = new CustomEvent('oTracking.event', options);
document.body.dispatchEvent(skipEvent);
break;
}
}

Expand Down

0 comments on commit 456bc51

Please sign in to comment.