X

How to change Google Ads and Google Analytic javascript to async

My website got loaded with google analytic and google ads javascript library hosted elsewhere in google server.
It will attempt to download and re-write some part of the content with the relevant ads. (yes, I got paid for that traffic . )

Recently with some optimisation done on the theme, it found out only the above javascript got WARNING, and it tried to perform document.write while the javascript file been deferred until all content being downloaded.

I was wondering how to make it work again.
Then I found this page at google support which provide guideline how to change it to async call instead of blocking call in previous version.

Here is how to do it.

For Google Ads:

Before:





After:






note : please edit the client-ad and slot id with yours.

For Google Analytic :

Change to:







and that’s it, it is now being deferred and making async call while loading the ads content.

Nice !!

Reference:
1. Adsense Support
2. Google Analytic

Namran Hussin: a soft spoken guy... with exceptional interest in computers and technology. I love to learn new thing and also love to break thing for the sake of learning.. but I do abide to the self-imposed limitation or certain thing such as social thing in life, thing can be done and thing that must be avoided at whatever cost such as drug,illegal tracking, smoke,illicit activity..etc.muahahaha let's share what we had in this short term of the life.! make it worth of the living.~
Related Post
Leave a Comment