Tuesday 2 May 2017

How to resolve Async XML parsing error when saving Google Adsense code in Blogger?



If you are a Blogger trying to integrate Google Adsense on your blog, you might have encountered and "async error" if you add the Google Adsense code in Blogger template as it is. Google Adsense provides JavaScript code which can be added to websites and blog platforms to display Google Ads. A typical Google Adsense (asynchronous) Code looks like this:


<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-XXXXXXXXXXXXXX",
    enable_page_level_ads: true
  });
</script>
 The error message on Blogger looks like this:


  "Attribute name "async" associated with an element type "script" must be followed by the ' = ' character."
In this post, we will see how to modify the Google Adsense code so that the error is resolve in Blogger templates.


If you get XML parsing error when adding Google Adsense code as it is in Blogger template, then modify the Google Adsense code a bit to resolve the error in Blogger.  A typical Google Adsense (Asynchronouse) code begins with:

<script async src="//pagead2.googlesyndication.com/pagead....</script>
<script>
 .......................................... </script>
  And the error says:

"Attribute name "async" associated with an element type "script" must be followed by the ' = ' character."
Which means, Blogger is expecting an equal sign (=) right after the word "async".



 Solution:
Add ="async" right after async in the Google Adsense code.

Before: Orginal Google Adsense code

 <script async src="//pagead2.googlesyndication.com/pagead....</script>
<script>
 .......................................... </script>
After: modified 

 <script async="async" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
 After the change, Blogger Template should save successfully without any XML parsing error.

 
Share:

0 comments:

Post a Comment

We love comment.

Your comment encourages us to serve you more...