Adding Google Adsense to Zaraz

Hi,

I would love to see Google Adsense added (particularly Auto-Ads) to Zaraz if that is possible.

EDIT: I have the Auto-Ads code inserted as HTML via Zaraz and it works. The only thing would be to add it for AMP. There are two pieces of code; they would need to be in the head and body of each page. Correct me if I am wrong but this sounds like the browser’s job, so I don’t see how it is possible via Zaraz?

EDIT 2: You cannot put the Auto-Ads code in Zaraz Custom HTML because it will also load for AMP. This duplicates ads and will cause AMP validation or performance issues via Core Web Vitals.

Thanks!
Tug

about EDIT 2

you can use that

if(window.location.href.indexOf("amp") > -1 ) {}else{ your code }

1 Like

Appreciate the response. However, it did not work.

if(window.location.href.indexOf("amp") > -1 ) {}else{ <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-12345678910111213" crossorigin="anonymous"></script> }

It is still populating on AMP pages.

You have to use a Page Rule to Block Zaraz. If you use a Blocking Trigger the code still executes. Likewise you can’t block running code with JavaScript… that would require running JavaScript of course!

No, thats a bad idea. Adslots and inserting pixels are different
zaraz - good for static pixel integration
ads requires dynamic insertion in fixed slots, ad-rotation, threshold setting for impressions, clicks etc

Cloudflare should have “Cloudflare adm” admediator feature
with atleast minimum features from openx and adbutler