Blogger (Blogspot) is Google's free blogging platform with a proprietary XML-based template system. Analytics issues on Blogger are unique because you cannot install npm packages, access server-side code, or use standard HTML injection methods. Everything goes through Blogger's template editor or the HTML/JavaScript gadget, both of which have strict parsing rules.
Blogger-Specific Debugging Approach
Blogger's template system transforms your code before serving it, which means what you paste is not always what the visitor receives. Always verify the rendered output.
Inspect the Actual Served HTML
Blogger rewrites certain HTML constructs. Check what actually ships:
// Paste in browser console on your Blogger site
// Check if your analytics tag made it through the template parser
document.querySelectorAll('script').forEach(s => {
if (s.src && (s.src.includes('gtag') || s.src.includes('gtm') || s.src.includes('analytics'))) {
console.log('Found:', s.src, '| async:', s.async, '| defer:', s.defer);
}
if (s.textContent && s.textContent.includes('gtag(')) {
console.log('Inline gtag script found, length:', s.textContent.length);
}
});
Template Editor vs. Gadget: Where Did You Put the Code?
Blogger has two places to add tracking code, and they behave differently:
- Theme > Edit HTML (template level): Code goes into the XML template. Blogger's parser may escape ampersands, strip CDATA sections, or reorder elements
- Layout > Add Gadget > HTML/JavaScript: Injected at render time. Fewer parsing issues but loads later in the DOM
Check both locations if tracking is intermittent.
Most Common Blogger Analytics Issues
1. Blogger XML Parser Escaping Your Tracking Code
Symptoms: Tag appears in the template editor but the rendered page has mangled JavaScript. Console shows syntax errors.
Root cause: Blogger's XML template parser treats & as an XML entity marker and may convert && to &&.
Fix: Wrap all inline JavaScript in a CDATA section:
<!-- In Blogger Template > Edit HTML, place inside <head> -->
<script>
//<![CDATA[
(function() {
var s = document.createElement('script');
s.async = true;
s.src = 'https://www.googletagmanager.com/gtag/js?id=G-XXXXXXX';
document.head.appendChild(s);
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXX');
})();
//]]>
</script>
2. Custom Domain Tracking Mismatch
Symptoms: Analytics works on yourblog.blogspot.com but not on blog.yourdomain.com. Pageviews show under the wrong hostname.
Root cause: Blogger serves the same content on both hostnames. If your GA property is configured for one but visitors arrive on the other, data splits across two hostnames.
Diagnosis:
// Check which hostname Blogger is serving
console.log('Current host:', window.location.hostname);
console.log('Blogger host:', document.querySelector('meta[content*="blogger"]')?.content);
Fix: Configure GA to accept both hostnames, or use GTM with a hostname override:
gtag('config', 'G-XXXXXXX', {
cookie_domain: 'yourdomain.com',
cookie_flags: 'SameSite=None;Secure'
});
3. Blogger's Built-in Stats Gadget Conflicting
Symptoms: Double pageview counts or analytics.js loading twice.
Root cause: Blogger injects its own stats tracking (/b/stats) automatically. If you also load Google Analytics, both may fire GA calls.
Fix: In Settings > Other > Site Feed, there's no toggle for stats, but you can check for duplicate GA properties:
// Check for multiple GA instances
console.log('GA instances:', window.google_tag_data?.ics?.entries?.length || 'none found');
console.log('Blogger stats:', document.querySelector('script[src*="/b/stats"]') ? 'ACTIVE' : 'not found');
4. Mobile Template Serving Different Code
Symptoms: Analytics works on desktop but not on mobile views.
Root cause: Blogger has a separate mobile template (?m=1). If you only added tracking to the desktop template, mobile visitors are untracked.
Fix: Either disable the mobile template (Settings > Formatting > Mobile template > No) to use the responsive desktop template, or add tracking code to both templates. Better approach — use a gadget instead of template injection, as gadgets appear on both views.
5. Blogspot CDN Cache Delay
Symptoms: You added tracking code but it doesn't appear for hours.
Root cause: Blogger aggressively caches through Google's CDN. Template changes can take 15-60 minutes to propagate.
Diagnosis:
# Check if CDN is serving cached version
curl -sI https://yourblog.blogspot.com/ | grep -iE "cache|age|etag|last-modified"
Fix: Force a cache bust by making a small content change (publish or update any post), then check again after 10 minutes. There is no manual CDN purge available on Blogger.
Environment Considerations
- Country-specific redirects: Blogger redirects visitors to country-code domains (e.g.,
yourblog.blogspot.co.uk). This can break cookie-based tracking. Usecookie_domain: 'auto'in GA configuration - AMP pages: Blogger auto-generates AMP versions at
/amp/paths. These require separate AMP analytics configuration - HTTPS enforcement: Blogger forces HTTPS. Mixed content from HTTP analytics endpoints will be silently blocked
- No server-side access: You cannot add HTTP headers, server-side GTM, or modify the serving infrastructure
Performance Issues
- LCP Issues - Blogger image hosting and template rendering delays
- CLS Issues - Layout shift from Blogger gadgets and ad injections
Tracking Issues
- Events Not Firing - Debug XML parser mangling, mobile template gaps, and CDN cache delays
Related Resources
- Blogger Template documentation
- Global Issues Hub for platform-agnostic solutions