Install Google Tag Manager (GTM) on Google Sites
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.
Comments
Want to join the conversation?
Loading comments...