Google Tag Manager — Channel Overview
Researched: May 2026
Why This Channel
Google Tag Manager is on virtually every Leadmetrics client website — it’s how they deploy Google Analytics, Meta Pixel, Google Ads conversion tracking, and other marketing tags. Yet the platform currently has no visibility into what tracking is actually deployed on a client’s site.
This matters for two reasons:
-
Agent accuracy — when the Site Auditor or Content Brief Writer recommends “add conversion tracking for your landing page”, it doesn’t know if GTM is already there or what tags are firing. GTM read access eliminates blind recommendations.
-
Setup automation — for clients who don’t have GA4 or Meta Pixel deployed, Leadmetrics can detect the gap from GTM data and generate a pre-configured tag template, saving the DM 30 minutes of manual setup per client.
This is a read-only analytics channel — it has no publishing capability. Auth reuses the existing Google OAuth infrastructure.
Auth Mechanism
Google OAuth 2.0 — reuse the existing Google provider infrastructure.
- Auth URL:
https://accounts.google.com/o/oauth2/v2/auth - Token URL:
https://oauth2.googleapis.com/token - Scopes:
https://www.googleapis.com/auth/tagmanager.readonly - Token refresh: same as all other Google channels
Sub-channel selection: after OAuth, the user selects which GTM Container to connect (clients may have multiple containers for different websites). Stored as subChannelInfo.id = containerId.
What It Enables
| Capability | Detail |
|---|---|
| Tag inventory | List all tags deployed in the container: GA4, Google Ads, Meta Pixel, LinkedIn Insight, etc. |
| Trigger analysis | What events fire which tags — identifies gaps (e.g. contact form submitted but no conversion tag) |
| Missing tracking detection | Auto-detect: no GA4 tag, no Meta Pixel, no conversion event on CTA buttons |
| Published vs draft | Compare live tags vs unpublished drafts — alert if outdated container is live |
| Agent context | Site Auditor gets a full tracking setup report before making recommendations |
Workers Needed
| Worker | Queue | Trigger |
|---|---|---|
gtm-sync.worker.ts (new) | agent__gtm-sync | On channel connect + weekly cron |
Feeds into: site-auditor.worker.ts | — | Passes tracking inventory as context |
Insight Worker Output (ChannelInsight)
- Total tags deployed; breakdown by tag type
- Missing critical tags (GA4 / Meta Pixel / Google Ads conversion) — flagged as high priority
- Tags firing on conversion pages (landing page, contact form) — verify completeness
- Last container publish date (alert if > 30 days old with unpublished changes)
- Suggested: specific tag setup instructions for detected gaps
Data Model
model GTMTagSnapshot {
id String @id @default(cuid())
tenantId String
channelId String
containerId String
accountId String
tags Json // Array of { tagId, name, type, firingTriggers[], status }
triggers Json // Array of { triggerId, name, type, conditions[] }
publishedAt DateTime?
snapshotDate DateTime @default(now())
tenant Tenant @relation(fields: [tenantId], references: [id])
channel ConnectedChannel @relation(fields: [channelId], references: [id])
@@index([tenantId])
@@index([channelId])
}Channel Detail Page — GoogleTagManagerChannelDetail.tsx
Tabs:
- Overview — container name, tag count, last published date
- Tags — full tag list sorted by type; missing critical tags highlighted in red
- Conversion Events — which events are tracked on CTA pages (contact form, purchase, sign-up)
- Insights — AI-generated tracking audit summary
- Suggestions — specific fixes for identified gaps
Implementation Plan
Phase 1 — Connect + Tag Inventory
-
Create
packages/providers/gtm/src/index.ts:getAccounts(accessToken)—GET /tagmanager/v2/accounts— list GTM accountsgetContainers(accessToken, accountId)—GET /tagmanager/v2/accounts/{id}/containersgetTags(accessToken, accountPath)—GET /tagmanager/v2/{parent}/workspaces/1/tagsgetTriggers(accessToken, accountPath)— triggers for each taggetContainerVersions(accessToken, containerPath)— published vs latest draftverify(accessToken)—GET /tagmanager/v2/accounts
-
Add OAuth routes to
apps/api/src/routers/channel-connect.ts:GET /googleTagManager/connect→ return auth URL (GTM-scoped)GET /googleTagManager/callback→ exchange code, redirect to container selectGET /googleTagManager/page/select→ list accounts + containersPOST /googleTagManager/page/select→ save selected container assubChannelInfo
-
Create
gtm-sync.worker.ts:- Fetch all tags + triggers → upsert
GTMTagSnapshot - Detect missing critical tags → create
ChannelInsightwith specific gaps
- Fetch all tags + triggers → upsert
-
Update
site-auditor.worker.tsto pull GTM snapshot as context when the channel is connected -
Add seed entry to
packages/db/prisma/seed.ts -
Create
GoogleTagManagerChannelDetail.tsx
Phase 2 — Agent Integration
-
Pass GTM tag inventory to the onboarding context pipeline — Site Auditor gets tracking setup as part of its initial analysis
-
“Fix this” actions on the Suggestions tab: for each missing tag, generate a downloadable GTM JSON tag template that the DM can import directly into GTM
Seed Entry
// packages/db/prisma/seed.ts — CHANNEL_CATALOGUE
{
type: "GoogleTagManager",
name: "Google Tag Manager",
iconKey: "google", // use Google icon; no standalone GTM icon in fa6
description: "Audit your tracking setup and detect missing conversion tags via Google Tag Manager.",
authenticationType: "oauth2",
requiresUrl: false,
isActive: true,
categories: ["seo", "performance_marketing"],
},