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:
The error message on Blogger looks like this:
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:
Solution:
Add ="async" right after async in the Google Adsense code.
Before: Orginal Google Adsense code
Alternative Way One:
Before:
<script async src="//pagead2.googlesyndication.com/pagead...."</script>
After:
Replace parts of the line containing "async" with the following.
1) Replace the starting part: <script async src=" with <script async src="
2) Replace the ending part: "</script> with "></script>
So the entire line containing async looks like this:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Blogger will now save the code without any error.
Alternate Way Two:
If you do not like to fiddle with the Adsense code on your own, you can also take help from online Adsense code parsers such as this Adsense Code Parser (click).
<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>And the error says:
<script>
.......................................... </script>
"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>After: modified
<script>
.......................................... </script>
<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.
Alternative Way One:
Before:
<script async src="//pagead2.googlesyndication.com/pagead...."</script>
After:
Replace parts of the line containing "async" with the following.
1) Replace the starting part: <script async src=" with <script async src="
2) Replace the ending part: "</script> with "></script>
So the entire line containing async looks like this:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Blogger will now save the code without any error.
Alternate Way Two:
If you do not like to fiddle with the Adsense code on your own, you can also take help from online Adsense code parsers such as this Adsense Code Parser (click).
- Go to the link above and paste the Google Adsense code as it is.
- Click Convert
- A parsed code will be generated.
- Copy the parsed code and paste it in the Blogger template page.
- Save the Theme.
do you use this same fix on this blog...?
ReplyDeleteHi,
DeleteYes I do. Without the edit, Blogger will always throw the XML parsing error.
Yea....I was also able to fix it instantly using THIS METHOD HERE
DeleteHi,
ReplyDeleteThank 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
Hi Diana.
DeleteThanks for your wonderful comment and I am glad the post was of help.
Cheers! Good Day!
how can we know that this modification in code approves the website after verifying?
ReplyDeleteIt will not work
Deletethankuh admin
ReplyDeletethanks from my heart
ReplyDeleteThanks it worked. Now waiting for approval :)
ReplyDeleteDid you get approval use this method?
DeleteThank you so mach
ReplyDeletewow yes its working now .... :)
ReplyDeleteThanks!
Albina
This has worked for me. You are a life saver Albina.
ReplyDeleteIs this still working in 2021?
ReplyDelete