Skip to Content
ChannelsGoogle Tag ManagerGoogle Tag Manager — Channel Overview

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:

  1. 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.

  2. 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

CapabilityDetail
Tag inventoryList all tags deployed in the container: GA4, Google Ads, Meta Pixel, LinkedIn Insight, etc.
Trigger analysisWhat events fire which tags — identifies gaps (e.g. contact form submitted but no conversion tag)
Missing tracking detectionAuto-detect: no GA4 tag, no Meta Pixel, no conversion event on CTA buttons
Published vs draftCompare live tags vs unpublished drafts — alert if outdated container is live
Agent contextSite Auditor gets a full tracking setup report before making recommendations

Workers Needed

WorkerQueueTrigger
gtm-sync.worker.ts (new)agent__gtm-syncOn channel connect + weekly cron
Feeds into: site-auditor.worker.tsPasses 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:

  1. Overview — container name, tag count, last published date
  2. Tags — full tag list sorted by type; missing critical tags highlighted in red
  3. Conversion Events — which events are tracked on CTA pages (contact form, purchase, sign-up)
  4. Insights — AI-generated tracking audit summary
  5. Suggestions — specific fixes for identified gaps

Implementation Plan

Phase 1 — Connect + Tag Inventory

  1. Create packages/providers/gtm/src/index.ts:

    • getAccounts(accessToken)GET /tagmanager/v2/accounts — list GTM accounts
    • getContainers(accessToken, accountId)GET /tagmanager/v2/accounts/{id}/containers
    • getTags(accessToken, accountPath)GET /tagmanager/v2/{parent}/workspaces/1/tags
    • getTriggers(accessToken, accountPath) — triggers for each tag
    • getContainerVersions(accessToken, containerPath) — published vs latest draft
    • verify(accessToken)GET /tagmanager/v2/accounts
  2. 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 select
    • GET /googleTagManager/page/select → list accounts + containers
    • POST /googleTagManager/page/select → save selected container as subChannelInfo
  3. Create gtm-sync.worker.ts:

    • Fetch all tags + triggers → upsert GTMTagSnapshot
    • Detect missing critical tags → create ChannelInsight with specific gaps
  4. Update site-auditor.worker.ts to pull GTM snapshot as context when the channel is connected

  5. Add seed entry to packages/db/prisma/seed.ts

  6. Create GoogleTagManagerChannelDetail.tsx

Phase 2 — Agent Integration

  1. Pass GTM tag inventory to the onboarding context pipeline — Site Auditor gets tracking setup as part of its initial analysis

  2. “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"], },

© 2026 Leadmetrics — Internal use only