davidrgreen / dfpeep

DFPeep is a Chrome extension that collects and presents data from GPT implementations and makes recommendations about likely issues.
MIT License
10 stars 0 forks source link

Enabling the extension breaks the DFP #2

Open nicholasio opened 6 years ago

nicholasio commented 6 years ago

Apparently enabling this extension breaks the ads on https://health.clevelandclinic.org/. If I disable the extensions the ads loads fine. Not sure if it's something wrong with the implementation on this particular website but the extension doesn't give me any error about the ads implementation.

Below is the error I'm getting

Exception in queued GPT command DOMException: Failed to execute 'postMessage' on 'Window': function () { wrapGPTRefresh(); wrapGPTEnableServices(); wrapGPTDefineSlot(); wrapGPTDefineOutO...<omitted>... } could not be cloned. at sendDataToDevTools (chrome-extension://lidjnpaobgnlghnjbjbfkehbajmigklo/page/page.js:674:10) at sendSlotDataToDevTools (chrome-extension://lidjnpaobgnlghnjbjbfkehbajmigklo/page/page.js:477:3) at Object.googletag.display (chrome-extension://lidjnpaobgnlghnjbjbfkehbajmigklo/page/page.js:508:4) at Arguments.<anonymous> (http://health.clevelandclinic.test/2018/01/can-stress-give-you-an-ulcer/:779:2325) at $m.push (https://securepubads.g.doubleclick.net/gpt/pubads_impl_179.js:1:63515) at $m.push (https://securepubads.g.doubleclick.net/gpt/pubads_impl_179.js:1:62169) at an (https://securepubads.g.doubleclick.net/gpt/pubads_impl_179.js:1:63870) at https://securepubads.g.doubleclick.net/gpt/pubads_impl_179.js:1:62169 at Hu (https://securepubads.g.doubleclick.net/gpt/pubads_impl_179.js:1:181132) at https://securepubads.g.doubleclick.net/gpt/pubads_impl_179.js:1:181765

davidrgreen commented 6 years ago

Hey Nícholas. Thanks for reporting this! I've pushed a quick fix to master to prevent this error from blocking execution, though I intend to do a more thorough fix later this week.

The root of the problem is that googletag.display() is being passed an object as an argument instead of a string. According to https://developers.google.com/doubleclick-gpt/reference#googletag.display it should only ever be sent a string equal to the ID of the element holding your ad slot.

This is happening in the following piece of code on the site:

googletag.enableServices(); for (var i = 0; i <= googletag.ccHealth.length; i++) {
   if (googletag.ccHealth[i]) googletag.display(googletag.ccHealth[i]);
}

If you use the browser console to look at the value of googletag.ccHealth with DFPeep disabled in order to rule out interference you'll see that one of the array values passed to it is a function. I'm not sure why that's happening without looking into it further, though I think it would be good to store this data outside the googletag object and in an object you create yourself to minimize the chance that other scripts are interacting with it unexpectedly.

nicholasio commented 6 years ago

Thanks for the fix and for catching that @davidrgreen. I'll dig into the issue you pointed out.