Hey guys,
I logged into my Google Search Console today to find that my website was marked “not verified”. Obviously it was verified before, but apparently Google attempted to reverify the property and it was unable to, and it gave me this as the reason why: “The Google Analytics tracking code on your site looks malformed.”
I looked into this further and it looks like the Google Analytics add-on is stripping a piece of code from the Analytics tracking code.
Here’s how the code should look, according to Google:
<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_TRACKING_ID');
</script>
Here’s how the code looks after you’ve copied & pasted the code into the Themeco add-on and pressed the UPDATE button:
<!-- Global Site Tag (gtag.js) - Google Analytics -->
https://www.googletagmanager.com/gtag/js?id=UA-[HIDDEN}
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-[HIDDEN]');
</script>
So the add-on is stripping the <script async> tag from Line 2 and only displaying the link.
Is this a bug that needs to be fixed? This is the only way I can verify my site in Search Console as of right now, and I have several other client sites that will need updating after this too.