Search This Blog

Saturday, September 17, 2016

Getting 'attribute name "async" must be followed by =' when trying to implement "page level adsense" in google blogger ?

Page-level adsense has finally arrived to my location, and as I was tiredly embedding the code generated by adsense, I was surprised to receive the following notice: 
"Error parsing XML, line XXXX, column YY: Attribute name "async" associated with an element type "script" must be followed by the ' = ' character."

If you experience the same problem, don't fret. 
the solution is simple. 
Blogger expects XML, so we'll use XHTML, and instead of async, write the formal XHTML async="async". 

This means that your code should look like the following (pay atention that the google-client-ad has been changed): 

<script async="async" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-XXXXXXXXXXXXXXXX",
    enable_page_level_ads: true
  });
</script>
That is all that is required to make the code work.