Search code examples
javascriptadsensedom-manipulationgoogle-publisher-tag

How can I access GPT data with pure javascript on browser console?


So I'm working on a website which renders ad banners on certain pages. How can I get the list of all the possible ad banners to render with pure javascript on the browser console? Currently the only way I am able to access this data is via the Google Publisher Console which is a popup.

There is the 'googletag' method which when I run in the console, gives me an object but I am unable to find the data for all the possible slots.

I'd like to be able to access the Ad Slots and programatically choose what to render.

Thanks.


Solution

  • This function I found will render all the page specific GPT data: https://gist.github.com/rdillmanCN/a70ec955d9a982127fefadabe8b898b5