Namran Hussin Blogger Stuff How to change Google Ads and Google Analytic javascript to async

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

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

Backup ServerBackup Server

“eh.. how come your website down ? have been suspended ?” .. ahaha.. “err…dun know..” .. kind of the shameful conversation after all… then i’ve decided to get some backup