Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to know if "disableInitialLoad" was called on GPT?

Tags:

google-dfp

gpt

I need to know if googletag.pubads().disableInitialLoad() was called, in which case I'll load an ad using a display and a refresh calls, otherwise I'll load it using just display. My assumption is that if I always call display plus refresh I will get 2 ad requests unless disableInitialLoad had been called.

Is it possible to know that?

like image 710
Tomas Romero Avatar asked Mar 13 '18 21:03

Tomas Romero


2 Answers

There is an undocumented variable on pubads that internally saves the state of disableInitialLoad, because it is undocumented you have to use it under your own risk.

the variable is window.google_DisableInitialLoad

Hope it is still usefull to you.

like image 98
Claudio Castro Avatar answered Oct 19 '22 12:10

Claudio Castro


There is a method in GPT for doing this which is: isInitialLoadDisabled()

And as Claudio wrote - it's good practice not to use undocumented variables. Undocumented variables might not do exactly what you think they do - and their behaviour might change at any point (see avoiding common GPT implementation mistakes).

like image 25
gernberg Avatar answered Oct 19 '22 13:10

gernberg