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

Async 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.



Comment with Facebook

Comments

  1. do you use this same fix on this blog...?

    ReplyDelete
    Replies
    1. Hi,
      Yes I do. Without the edit, Blogger will always throw the XML parsing error.

      Delete
    2. Yea....I was also able to fix it instantly using THIS METHOD HERE

      Delete
  2. Hi,
    Thank you so much for your help! I had no idea how to fix this on my art blog but now no error is showing. :) Have a nice day!
    Diana from ftrabbitstudios.blogspot.com

    ReplyDelete
    Replies
    1. Hi Diana.
      Thanks for your wonderful comment and I am glad the post was of help.
      Cheers! Good Day!

      Delete
  3. how can we know that this modification in code approves the website after verifying?

    ReplyDelete
  4. Thanks it worked. Now waiting for approval :)

    ReplyDelete

Post a Comment