Last active
April 22, 2020 17:05
-
-
Save fIa5h/aa9c921e41eb7a1c41f13b4e5e139a09 to your computer and use it in GitHub Desktop.
Ryan & Bruce
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
New Relic GPT ad monitoring code | |
// | |
This snippet captures PageActions containing references to Google publisher tag ads | |
Should you have any questions about this, please reach out to me at [email protected] | |
Please note that you must be using New Relic's SPA browser agent. | |
// | |
*/ | |
// | |
//first, make sure the newrelic object exists properly | |
if(typeof newrelic !== "undefined"){ | |
if(typeof newrelic.addPageAction !== "undefined"){ | |
// | |
// | |
googletag.cmd.push(function () { | |
// | |
// | |
// ** impressionViewable ** | |
/* | |
This event is fired when the ad becomes 'visible' to the end user. | |
- For ads, 50% of the ad’s pixels are visible in the browser window for a continuous 1 second. | |
- For larger ads (those greater than 242,000 pixels), 30% of the ad’s pixels are visible in the browser window. | |
- For in-stream video ads, 50% of the ad’s pixels must be visible in the browser window for a continuous 2 seconds. | |
See docs: https://developers.google.com/doubleclick-gpt/reference#googletageventsimpressionviewableevent | |
*/ | |
googletag.pubads().addEventListener('impressionViewable', function(event) { | |
newrelic.addPageAction('impressionViewable', event); | |
}); | |
// | |
// | |
// | |
// | |
// ** slotOnload ** | |
/* | |
This event is fired when the creative's iframe fires its load event. | |
When rendering rich media ads in sync rendering mode, no iframe is used so no SlotOnLoadEvent will be fired. | |
See docs: https://developers.google.com/doubleclick-gpt/reference#googletageventsslotonloadevent | |
*/ | |
googletag.pubads().addEventListener('slotOnload', function(event) { | |
newrelic.addPageAction('slotOnload', event); | |
}); | |
// | |
// | |
// | |
// | |
// ** slotRenderEnded ** | |
/* | |
This event is fired when the creative code is injected into a slot. | |
This event will occur before the creative's resources are fetched, so the creative may not be visible yet. | |
The event is fired by the service that rendered the slot. | |
Example: To listen to companion ads, add a listener to the companion ads service, not the pubads service. | |
Note: If you need to know when the creative has fired its load event, consider the SlotOnloadEvent. | |
See docs: https://developers.google.com/doubleclick-gpt/reference#googletageventsslotrenderendedevent | |
*/ | |
googletag.pubads().addEventListener('slotRenderEnded', function(event) { | |
newrelic.addPageAction('slotRenderEnded', event); | |
}); | |
// | |
// | |
// | |
// | |
}); | |
// | |
// | |
} | |
} | |
// | |
// | |
/* | |
END New Relic GPT ad monitoring code | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment