Install Google Tag Manager (GTM) on Google Sites

Loves Data
Loves DataMar 25, 2026

Why It Matters

Marketers can now manage analytics, ads, and conversion tags on Google Sites without native GTM support, but must weigh the flexibility of Cloudflare against potential future breakage.

Key Takeaways

  • Use Cloudflare Workers to inject GTM code site-wide.
  • Enable Cloudflare proxy on CNAME record before deploying worker.
  • Embed option fails due to sandboxed iframe encoding in sites.
  • Test GTM via Tag Assistant preview after deployment.
  • Consider native Google Analytics integration for stability and reliability.

Summary

The video walks through a workaround for adding Google Tag Manager (GTM) to a Google Sites web property by leveraging Cloudflare’s edge platform. Because Google Sites lacks a built‑in GTM integration, the presenter configures the domain’s CNAME to route through Cloudflare, enables the proxy, and then creates a Cloudflare Worker that injects the GTM container snippet into every page.

Key steps include: editing the CNAME record, deploying a Worker with custom JavaScript that contains the GTM container ID, and assigning a route (/*) so the script runs site‑wide. After publishing, the author validates the setup using GTM’s Preview mode and Tag Assistant, confirming that the container loads correctly.

The tutorial also explains why the common “Embed” method fails—Google Sites encodes the snippet inside a sandboxed iframe, isolating it from the page and preventing GTM from executing. A quick source‑code inspection shows the encoded ID, reinforcing the need for an edge‑injection approach.

While functional, the method is unofficial and may break if Google changes Sites’ architecture. The presenter advises testing thoroughly and suggests using Google’s native Analytics integration for a more stable solution, warning against duplicate tag installations that could skew data.

Original Description

Learn how to install Google Tag Manager on Google Sites using Cloudflare, and find out why the popular 'Embed' method doesn't actually work. I'll walk you through setting up a Cloudflare Worker to inject the GTM container code across all pages of your site, how to verify the installation using Tag Assistant, and when it makes more sense to use Google's built-in Google Analytics integration instead.
JUMP TO A TOPIC:
00:00 Introduction
01:37 Installing GTM on Google Sites with Cloudflare
05:46 Why the Google Sites 'Embed' option doesn't work
07:38 Using the built-in Google Analytics integration
08:48 Next steps
YOUR EXTRA RESOURCES:
TOOLS WE USE AND RECOMMEND:
○ Data connector – https://lovesdata.co/oOWkI
○ Cookie banner – https://lovesdata.co/letON
○ Email platform – https://lovesdata.co/zrLd7
○ Course platform – https://lovesdata.co/2Zzfq
#GoogleTagManager #GoogleSites #GTM #GoogleTagManagerTutorial #Cloudflare #CloudflareWorkers #GoogleAnalytics #DigitalMarketing #WebAnalytics #TagManagement

Comments

Want to join the conversation?

Loading comments...