Blogger Analytics Integrations: Setup Guide | OpsBlu Docs

Blogger Analytics Integrations: Setup Guide

Integrate GA4, GTM, and Meta Pixel with Blogger using the HTML/JavaScript gadget, theme XML editing, and the Layout editor.

Blogger (blogspot.com) is Google's free blogging platform with a unique integration model. Unlike most CMS platforms, Blogger does not support server-side code, plugins, or package managers. All third-party integrations must go through the theme XML editor, the Layout gadget system, or Blogger's built-in analytics settings.

Integration Architecture

Blogger's integration surface is limited to three mechanisms:

  1. Layout Gadgets -- Drag-and-drop widgets added via Blogger Dashboard > Layout. The HTML/JavaScript gadget accepts arbitrary <script> tags.
  2. Theme XML Editing -- Direct edits to the Blogger theme XML via Theme > Edit HTML. This gives full control over <head> and <body> injection points.
  3. Built-in Settings -- Settings > Basic > Google Analytics Property ID accepts a GA4 Measurement ID directly (no code needed).

There is no plugin ecosystem, no server-side rendering, and no build step. Every integration is client-side JavaScript injected into the page template.

Available Integrations

Analytics Platforms

Google Analytics 4

  • Native Blogger setting (Measurement ID only, basic pageviews)
  • Theme XML injection (full gtag.js with custom events)
  • GTM-based implementation (recommended for multiple tools)

Tag Management

Google Tag Manager

  • Theme XML head/body injection (only reliable method)
  • HTML/JavaScript gadget (limited -- loads after page content)

Marketing Pixels

Meta Pixel

  • Theme XML head injection
  • No server-side Conversions API (Blogger has no backend)

Integration Methods

Method 1: Built-in GA4 Setting (Simplest)

Navigate to Settings > Basic > Google Analytics Property ID and enter your Measurement ID (G-XXXXXXXXXX). This provides basic pageview tracking with zero code. It does not support custom events, enhanced measurement configuration, or ecommerce tracking.

Open Theme > Customize > Edit HTML and locate the <head> section. Insert tracking scripts immediately after the opening <head> tag:

<head>
  <!-- Google Tag Manager -->
  <script>
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&amp;l='+l:'';j.async=true;
    j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;
    f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-XXXX');
  </script>
  <!-- End Google Tag Manager -->

  <!-- existing head content -->
  <b:include data='blog' name='all-head-content'/>

Note the use of &amp; instead of & -- Blogger's XML parser requires HTML entity encoding inside theme templates.

Method 3: HTML/JavaScript Gadget

Add a gadget via Layout > Add a Gadget > HTML/JavaScript. Paste your tracking script in the content field. This approach loads the script wherever the gadget is placed in the layout, which is typically in the sidebar or footer -- not ideal for tracking scripts that need to fire early.

Building a Data Layer

Blogger exposes page data through its XML template language. You can build a data layer using Blogger's conditional tags:

<script>
  window.dataLayer = window.dataLayer || [];
  window.dataLayer.push({
    'pageType': '<b:if cond="data:blog.pageType == &quot;item&quot;">post<b:elseif cond="data:blog.pageType == &quot;static_page&quot;"/>page<b:elseif cond="data:blog.pageType == &quot;index&quot;"/>index<b:else/>other</b:if>',
    'blogTitle': '<data:blog.title/>',
    'pageTitle': '<data:blog.pageName/>',
    'postLabels': '<b:if cond="data:blog.pageType == &quot;item&quot;"><b:loop values="data:post.labels" var="label"><data:label.name/>,</b:loop></b:if>'
  });
</script>

Available Blogger template variables for tracking:

  • data:blog.pageType -- item (post), static_page, index, archive, error_page
  • data:blog.title -- Blog name
  • data:blog.pageName -- Current page/post title
  • data:post.labels -- Post category labels (only on post pages)
  • data:blog.url -- Current page URL
  • data:blog.homepageUrl -- Blog root URL

Platform Limitations

No server-side code. Blogger runs entirely on Google's infrastructure with no backend access. Server-side tracking (Meta Conversions API, GA4 Measurement Protocol server-side) requires an external server or cloud function to proxy events.

XML entity encoding. All JavaScript inside the theme XML must use &amp; for &, &lt; for <, and &gt; for > when outside of CDATA blocks. Alternatively, wrap scripts in <![CDATA[ ... ]]> sections.

No ecommerce capabilities. Blogger has no cart, checkout, or product pages. Ecommerce tracking events (purchase, add_to_cart) are not applicable unless using a third-party storefront embedded via iframe.

Custom domain caching. Blogger aggressively caches pages served on custom domains. After editing the theme XML, changes may take 10-30 minutes to appear on the live site. Use the blogspot.com URL to verify changes immediately.

Gadget load order. HTML/JavaScript gadgets load in DOM order, which means sidebar gadgets load after the main content area. For tracking scripts that need early execution, theme XML injection is the only reliable option.

Performance Considerations

Blogger serves pages from Google's CDN with aggressive caching, so baseline performance is typically good. However:

  • Third-party script budget is tight. Blogger pages are lightweight HTML. Adding GTM plus multiple pixels can double the total JavaScript payload.
  • No build step or bundling. You cannot tree-shake or minify tracking code. Every byte loads as-is.
  • No async attribute in gadgets. Scripts added via the HTML/JavaScript gadget load synchronously by default. Theme XML injection lets you add async or defer attributes.
  • Image-heavy blogs suffer most. On blogs with large hero images, additional tracking scripts compete with image loading for bandwidth. Prioritize lightweight implementations.
  1. GTM via theme XML -- Single container handles all tracking. Add the GTM snippet in <head> and the <noscript> iframe after <body>.
  2. GA4 via GTM -- Configure GA4 as a tag inside GTM rather than using Blogger's built-in setting (more control over events and configuration).
  3. Meta Pixel via GTM -- Add as a Custom HTML tag in GTM. Since there is no Conversions API on Blogger, client-side pixel is the only option.

Next Steps

For general integration concepts, see the integrations overview.