Prototype · Preview: every server in the official registry, synced every 30 minutes. Sign in with Google to write reviews.Prototype · updated every 30 min
PopNx MCPMCP servers for people who use AI · explained in plain words

Samarth Gtm MCP

by samarthanalytics-sjversion 1.19.0i★ 3iRuns on your computer
Registry nameio.github.samarthanalytics-sj/samarth-gtm-mcp

How to install

What it does

Google Tag Manager + read-only GA4 MCP server. Read-only by default, gated writes, audits.

  • Connects Runs on your computer
  • Account or key Needs GOOGLE_OAUTH_CLIENT_SECRET · 1 setting to fill in (GOOGLE_OAUTH_CLIENT_ID)
  • Category Other

Install

Pick the AI app you use, then copy the settings.

Passed 3/3 checks · Runs on your computer · ✓ Commands checked Nov 14, 2026

First: which AI do you use?

Pick your app and the steps appear below.

Works with Claude, with some setup first

You need a Samarth Gtm MCP key (create it on the maker’s site) · 1 setting(s) to fill in (GOOGLE_OAUTH_CLIENT_ID) · Install Node.js on your computer first (one time) · Only the Claude desktop app (Windows or Mac), not the web or phone

  1. Install Node.js

    One time only; it works for every server that needs Node.js

    Open the Node.js download page ↗

  2. Sign up and create a Samarth Gtm MCP key

    Open the maker’s site, sign up and create an API key for the next step. Check the maker’s site for pricing and free plans.

    How to get a key is in the maker’s README below

  3. Fill in 1 setting(s)

    These are program settings, not keys. No sign-up needed; fill them in as the maker describes.

    • GOOGLE_OAUTH_CLIENT_ID Your Google OAuth 2.0 client ID (Desktop app type)

    Descriptions are as written by the maker.

  4. Open the Claude desktop app’s settings file

    SettingsDeveloperEdit Config

  5. Paste these settings and save the file

    {
      "mcpServers": {
        "samarth-gtm": {
          "command": "npx",
          "args": [
            "-y",
            "samarth-gtm-mcp"
          ],
          "env": {
            "GOOGLE_OAUTH_CLIENT_ID": "your-value",
            "GOOGLE_OAUTH_CLIENT_SECRET": "your-value"
          }
        }
      }
    }

    Paste the key only into the app’s field, never into a chat or to anyone

  6. Quit Claude and open it again

  7. Try it

    Use Samarth Gtm MCP and tell me what you can do for me, then show me one thing

    ✓ If Claude says it is using Samarth Gtm MCP or shows a Samarth Gtm MCP tool in the answer, you are connected

3 optional setting(s) (works without them)

The command above works without these. Add them only if you want to change something, following the maker’s description.

  • GTM_MCP_ENABLE_WRITES Set to 'true' to allow create/update operations (default: read-only)
  • GTM_MCP_ENABLE_PUBLISH Set to 'true' to allow publish operations (default: disabled)
  • GTM_MCP_ENABLE_DELETES Set to 'true' to allow delete operations (default: disabled)

Descriptions are as written by the maker.

Menu names checked against Anthropic’s help page on Nov 11, 2026 · your screen may differ slightly by app version

ChatGPT cannot connect Samarth Gtm MCP yet

Samarth Gtm MCP runs on your computer, but ChatGPT can only connect servers that run on the web

What you can do instead

A · Use an app that can connect Samarth Gtm MCP

  • You need a Samarth Gtm MCP key (create it on the maker’s site) · 1 setting(s) to fill in (GOOGLE_OAUTH_CLIENT_ID) · Install Node.js on your computer first (one time) · Only the Claude desktop app (Windows or Mac), not the web or phone
  • You need a Samarth Gtm MCP key (create it on the maker’s site) · 1 setting(s) to fill in (GOOGLE_OAUTH_CLIENT_ID) · Install Node.js on your computer first (one time)
  • You need a Samarth Gtm MCP key (create it on the maker’s site) · 1 setting(s) to fill in (GOOGLE_OAUTH_CLIENT_ID) · Install Node.js on your computer first (one time)
  • You need a Samarth Gtm MCP key (create it on the maker’s site) · 1 setting(s) to fill in (GOOGLE_OAUTH_CLIENT_ID) · Install Node.js on your computer first (one time)

B · Others in Other that work with ChatGPT

Picked from the most used in the same category, only ones that connect by address with no key

Works with Claude Code, with some setup first

You need a Samarth Gtm MCP key (create it on the maker’s site) · 1 setting(s) to fill in (GOOGLE_OAUTH_CLIENT_ID) · Install Node.js on your computer first (one time)

  1. Install Node.js

    One time only; it works for every server that needs Node.js

    Open the Node.js download page ↗

  2. Sign up and create a Samarth Gtm MCP key

    Open the maker’s site, sign up and create an API key for the next step. Check the maker’s site for pricing and free plans.

    How to get a key is in the maker’s README below

  3. Fill in 1 setting(s)

    These are program settings, not keys. No sign-up needed; fill them in as the maker describes.

    • GOOGLE_OAUTH_CLIENT_ID Your Google OAuth 2.0 client ID (Desktop app type)

    Descriptions are as written by the maker.

  4. Open Terminal

    Mac: press Command+Space and type Terminal · Windows: open PowerShell

  5. Paste this command and press Enter

    claude mcp add --scope user samarth-gtm --env GOOGLE_OAUTH_CLIENT_ID=your-value --env GOOGLE_OAUTH_CLIENT_SECRET=your-value -- npx -y samarth-gtm-mcp

    Replace “your-value” with your key before pressing Enter

    Paste the key only into the app’s field, never into a chat or to anyone

  6. Type /mcp in Claude Code

    You should see Samarth Gtm MCP listed as connected

  7. Try it

    Use Samarth Gtm MCP and tell me what you can do for me, then show me one thing

    ✓ If Claude Code says it is using Samarth Gtm MCP or shows a Samarth Gtm MCP tool in the answer, you are connected

3 optional setting(s) (works without them)

The command above works without these. Add them only if you want to change something, following the maker’s description.

  • GTM_MCP_ENABLE_WRITES Set to 'true' to allow create/update operations (default: read-only)
  • GTM_MCP_ENABLE_PUBLISH Set to 'true' to allow publish operations (default: disabled)
  • GTM_MCP_ENABLE_DELETES Set to 'true' to allow delete operations (default: disabled)

Descriptions are as written by the maker.

Menu names checked against Anthropic’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Works with Cursor, with some setup first

You need a Samarth Gtm MCP key (create it on the maker’s site) · 1 setting(s) to fill in (GOOGLE_OAUTH_CLIENT_ID) · Install Node.js on your computer first (one time)

  1. Install Node.js

    One time only; it works for every server that needs Node.js

    Open the Node.js download page ↗

  2. Sign up and create a Samarth Gtm MCP key

    Open the maker’s site, sign up and create an API key for the next step. Check the maker’s site for pricing and free plans.

    How to get a key is in the maker’s README below

  3. Fill in 1 setting(s)

    These are program settings, not keys. No sign-up needed; fill them in as the maker describes.

    • GOOGLE_OAUTH_CLIENT_ID Your Google OAuth 2.0 client ID (Desktop app type)

    Descriptions are as written by the maker.

  4. Click this button to open Cursor

    Open in Cursor

    Cursor asks you to confirm; click Install

  5. Fill in your key

    In the Samarth Gtm MCP settings, GOOGLE_OAUTH_CLIENT_SECRET, GOOGLE_OAUTH_CLIENT_ID is empty; add your key and save

    Paste the key only into the app’s field, never into a chat or to anyone

  6. Open the AI chat in Cursor in Agent mode

  7. Try it

    Use Samarth Gtm MCP and tell me what you can do for me, then show me one thing

    ✓ If Cursor says it is using Samarth Gtm MCP or shows a Samarth Gtm MCP tool in the answer, you are connected

3 optional setting(s) (works without them)

The command above works without these. Add them only if you want to change something, following the maker’s description.

  • GTM_MCP_ENABLE_WRITES Set to 'true' to allow create/update operations (default: read-only)
  • GTM_MCP_ENABLE_PUBLISH Set to 'true' to allow publish operations (default: disabled)
  • GTM_MCP_ENABLE_DELETES Set to 'true' to allow delete operations (default: disabled)

Descriptions are as written by the maker.

Menu names checked against Cursor’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Works with VS Code, with some setup first

You need a Samarth Gtm MCP key (create it on the maker’s site) · 1 setting(s) to fill in (GOOGLE_OAUTH_CLIENT_ID) · Install Node.js on your computer first (one time)

  1. Install Node.js

    One time only; it works for every server that needs Node.js

    Open the Node.js download page ↗

  2. Sign up and create a Samarth Gtm MCP key

    Open the maker’s site, sign up and create an API key for the next step. Check the maker’s site for pricing and free plans.

    How to get a key is in the maker’s README below

  3. Fill in 1 setting(s)

    These are program settings, not keys. No sign-up needed; fill them in as the maker describes.

    • GOOGLE_OAUTH_CLIENT_ID Your Google OAuth 2.0 client ID (Desktop app type)

    Descriptions are as written by the maker.

  4. Click this button to open VS Code

    Open in VS Code

    VS Code asks you to confirm; click Install

  5. Fill in your key

    In the Samarth Gtm MCP settings, GOOGLE_OAUTH_CLIENT_SECRET, GOOGLE_OAUTH_CLIENT_ID is empty; add your key and save

    Paste the key only into the app’s field, never into a chat or to anyone

  6. Open the AI chat in VS Code in Agent mode

  7. Try it

    Use Samarth Gtm MCP and tell me what you can do for me, then show me one thing

    ✓ If VS Code says it is using Samarth Gtm MCP or shows a Samarth Gtm MCP tool in the answer, you are connected

3 optional setting(s) (works without them)

The command above works without these. Add them only if you want to change something, following the maker’s description.

  • GTM_MCP_ENABLE_WRITES Set to 'true' to allow create/update operations (default: read-only)
  • GTM_MCP_ENABLE_PUBLISH Set to 'true' to allow publish operations (default: disabled)
  • GTM_MCP_ENABLE_DELETES Set to 'true' to allow delete operations (default: disabled)

Descriptions are as written by the maker.

Menu names checked against VS Code’s help page on Nov 11, 2026 · your screen may differ slightly by app version

Other apps that use MCP, such as Windsurf, Zed or Gemini CLI, each add servers differently. See how in the app list.

See every app that uses MCP →

JSON settings are under “For developers” below

Stuck? Ask people who use Samarth Gtm MCP💬 Discussion →
For developers: Terminal commands and JSON settings

Installed on your computer

Claude Code

claude mcp add --scope user samarth-gtm --env GOOGLE_OAUTH_CLIENT_ID=your-value --env GOOGLE_OAUTH_CLIENT_SECRET=your-value -- npx -y samarth-gtm-mcp

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "samarth-gtm": {
      "command": "npx",
      "args": [
        "-y",
        "samarth-gtm-mcp"
      ],
      "env": {
        "GOOGLE_OAUTH_CLIENT_ID": "your-value",
        "GOOGLE_OAUTH_CLIENT_SECRET": "your-value"
      }
    }
  }
}

Cursor (~/.cursor/mcp.json)

{
  "mcpServers": {
    "samarth-gtm": {
      "command": "npx",
      "args": [
        "-y",
        "samarth-gtm-mcp"
      ],
      "env": {
        "GOOGLE_OAUTH_CLIENT_ID": "your-value",
        "GOOGLE_OAUTH_CLIENT_SECRET": "your-value"
      }
    }
  }
}

VS Code (mcp.json)

{
  "servers": {
    "samarth-gtm": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "samarth-gtm-mcp"
      ],
      "env": {
        "GOOGLE_OAUTH_CLIENT_ID": "your-value",
        "GOOGLE_OAUTH_CLIENT_SECRET": "your-value"
      }
    }
  }
}

Values you fill in

  • GOOGLE_OAUTH_CLIENT_ID required env
    Your Google OAuth 2.0 client ID (Desktop app type)
  • GOOGLE_OAUTH_CLIENT_SECRET secret required env
    Your Google OAuth 2.0 client secret
  • GTM_MCP_ENABLE_WRITES env
    Set to 'true' to allow create/update operations (default: read-only)
  • GTM_MCP_ENABLE_PUBLISH env
    Set to 'true' to allow publish operations (default: disabled)
  • GTM_MCP_ENABLE_DELETES env
    Set to 'true' to allow delete operations (default: disabled)

Descriptions are as written by the maker.

These settings are generated from the maker’s registry entry. If the README says otherwise, follow the README.

At a glance

Downloads per weeki
164/wk
Connection
Runs on your computer
Latest versioni
1.19.0
Categoryi
Other
Published to registryi
Jun 12, 2026
Code last changedi
Nov 13, 2026
Maker
samarthanalytics-sj
Packages
npm: samarth-gtm-mcp
Registry status
Active

Which apps can use it

Based on how this server connects and on each app’s own docs, checked Nov 10, 2026.

Run on your computer in

ClaudeGooseLM StudioMsty StudioCherry StudioCursorVS Code + GitHub CopilotVisual StudioWindsurf (Devin Desktop)ZedKiroClineContinueJetBrains AI AssistantClaude CodeCodex CLIGemini CLIOpenCodenodecodeWarpLibreChatRaycast

All apps, with pros and cons →

Related guides

What it can do

Runs on your computer; the tool list appears in your AI app after you install it.

Basic checksi

We check information anyone can see; we have not read the code. Checks that do not apply are left out of the count. · Checked Nov 14, 2026

  • ✓ Pass

    Maker matches the repo

    The registry name was verified with the GitHub account samarthanalytics-sj, which owns the repo

  • ✓ Pass

    Still maintained

    Code last changed yesterday

  • ✓ Pass

    Has a licence

    Uses MIT

  • – Not applicable

    Endpoint responds

    This one runs on your computer; there is no internet endpoint

  • – Not applicable

    Sign-in with OAuth

    Runs on your computer and uses local settings instead

  • … Not checked yet

    No hidden instructions in tool descriptions

    Runs on your computer; we can only read tool lists from internet endpoints

Discussion

Ask, share a tip or report that it does not work. Sorted by what people marked helpful.

No posts yet. Be the first to ask or share.

Posts here are written by users, not the PopNx team.

Sign in with Google to post

User reviews

No reviews yet

Sign in with Google to write a review

Compared with others in Otheri

  • More stars than 93% of the other 19738 servers in this category
  • Published to the registry more recently than 9% of the other 19738 servers in this category
  • Basic checks equal to or better than 100% of the other 19738 servers in this category

Compared with every active server in this category in the registry. Stars count only when the publisher owns the repo.

Common questions

Is Samarth Gtm MCP safe?

It passed 3 of 3 applicable basic checks. We have not read the code. Before adding a key or token, see what access the server asks for and use a key with only the permissions you need.

What keys or codes does it need?

You need to fill in: GOOGLE_OAUTH_CLIENT_SECRET

Does it run on my computer or in the cloud?

It runs on your computer. Your AI app starts it when needed, and data does not pass through the maker’s servers (unless it calls an online service itself).

Is it still maintained?

The GitHub repo last changed yesterday, and the latest version (1.19.0) reached the registry 5 months ago.

Which apps can use it?

Apps that support MCP, such as Claude Desktop, Claude Code, Cursor and VS Code. You also need Node.js on your computer.

What can I use instead?

In the same category: World Monitor, Claude Flow, Windmill

Others in the same category

Servers in the same category from other makers, sorted by stars.

Reading a card:↓ Downloads per weeki★ GitHub starsiThree pillars: reviews · checks · usageiUpdated = latest version published to the registryi

World Monitor

Real-time global intelligence on conflict, markets, energy, trade, shipping and cyber. 97 tools.

by koala73Widely used★ 90.6KUpdated yesterday

Runs in the cloud✓ service owner · worldmonitor.app

Claude Flow

AI orchestration with hive-mind swarms, neural networks, and 87 MCP tools for enterprise dev.

by ruvnetWidely used↓ 13.5K/wk★ 81.6KUpdated 14 months ago

Runs on your computer

Windmill

Run Windmill scripts and flows and manage jobs, schedules, resources and variables.

by windmill-labsWidely used★ 18.6KUpdated 2 days ago

Runs in the cloud

README from the maker

Open the README

Copied from the maker’s repo as written. PopNx MCP has not reviewed or endorsed it. HTML, images and scripts are removed. Links lead off this site.

Samarth Analytics MCP

An open-source Model Context Protocol (MCP) server that lets AI assistants such as Claude Desktop, Claude Code and Cursor work with Google Tag Manager and GA4. It covers the full GTM API v2 surface (100+ tools, including server-side containers), the GA4 Admin and Data APIs, a built-in implementation audit, and a second server that crawls a website to check its tags and Consent Mode v2 setup. Built by Samarth Analytics for our own client work and released under the MIT license for the analytics community.

Read-only by default. Creating, updating, publishing and deleting are each behind a separate environment flag, every write also requires confirm=true, and a dry-run mode simulates writes without touching the API. See Guardrails.

Use it at your own risk, and start on a dummy container. The server acts with your Google credentials, so every change it makes is yours. Try it first on a sandbox GTM container and a test GA4 property, keep the write flags off until you have watched how it behaves, and review the container's version history after any write session. We run it in production, but your setup is not ours.

Three ways to use it

What you getWhere to start

| Hosted, no install | Our community instance at https://mcp.samarthanalytics.com/mcp. Sign in with your own Google account; it only sees your containers and properties, and it is locked to read-only. Shared, best-effort, no uptime promise. | Add it to your MCP client with mcp-remote: {"mcpServers":{"samarth-gtm":{"command":"npx","args":["mcp-remote@next","https://mcp.samarthanalytics.com/mcp"]}}} | | Local | The server on your machine over stdio, with your own Google OAuth client, and the write flags under your control. | Quick Start and Google Cloud OAuth Setup | | Self-hosted | The MCP server, the web-audit server and the capture worker as one docker-compose stack behind your own token. | docs/SELF_HOSTING_DOCKER.md and Cloud Deployment |

The repo also ships Samarth Desktop, a local Electron app with a chat UI that embeds this server (Quick Start), and a browser-based customer portal in apps/portal/ that runs live, read-only QC audits.

Contributions are welcome. Bug reports with a reproducible container setup are the most useful thing you can send. Read CONTRIBUTING.md first; CI runs on every pull request.


Table of Contents

  1. Features
  2. Quick Start
  3. Google Cloud OAuth Setup
  4. Service Account Limitations
  5. Environment Variables Reference
  6. Guardrails
  7. Available Tools
  8. Cloud Deployment
  9. Security Notes
  10. Development
  11. Releases
  12. Troubleshooting

Features

  • Full GTM API v2 surface — accounts, containers, workspaces, tags, triggers, variables, folders, built-in variables, versions, sync, publish, preview
  • Server-side & advanced GTM coverage — environments, user permissions, destinations, clients, transformations, zones, custom templates, gtag config, plus container snippet/lookup/combine/move-tag-id and workspace change-diff status
  • GA4 coverage — GA4 Admin tools (ga4_*) plus GA4 Data API reporting (ga4_run_report, ga4_run_realtime_report) for intent-vs-reality reconciliation. Reads and reporting need only analytics.readonly; the GA4 Admin write tools are off by default behind GA4_MCP_ENABLE_WRITES / GA4_MCP_ENABLE_DELETES and additionally need analytics.edit
  • Automatic pagination — every paginated list tool transparently follows nextPageToken to return all results, with optional maxPages/pageToken bounds
  • Retry with exponential backoff + jitter — transient Google API failures (HTTP 408/429/5xx, network errors) on read requests are retried automatically; mutations are never auto-retried (tunable via GTM_MCP_RETRY_*)
  • Two transport modes: stdio (local, for Claude Desktop/Cursor) and Streamable HTTP (cloud/team)
  • Guardrails by default: read-only unless explicitly enabled; publish and delete gated separately
  • Dry-run mode: simulate all writes without touching the API
  • `confirm=true` required on all write/delete/publish operations
  • Audit tool: inspects workspace for common GA4/GTM implementation issues
  • Export tool: full workspace dump as structured JSON
  • Zod schema validation on all inputs
  • Detailed Google API error messages surfaced to the MCP client

Quick Start

The way to run Samarth is the desktop app - a local Electron app with a chat UI that embeds the MCP server in-process. Multi-account Google sign-in, per-account LLM keys (OpenAI / Anthropic / Gemini), secrets in the OS keychain. Nothing to configure by hand: the Google OAuth client and your LLM key are entered in the app on first run.

You need: Node.js 18 or newer, Git, and a free Google "Desktop app" OAuth client - two values you create once in your Google Cloud project (exact click-by-click steps).

git clone https://github.com/samarthanalytics-sj/samarth-analytics-mcp.git

cd samarth-analytics-mcp/apps/desktop npm install # downloads the Electron binary (~100 MB first time) npm run dev

The window opens; paste your OAuth client ID + secret and an LLM API key when asked, sign in to Google, and start chatting with your GTM / GA4 setup.

Prefer a config file over typing in the app? Put the OAuth client in a .env file instead - the app reads it on launch (values typed in the app and real shell variables always take precedence):

GOOGLE_DESKTOP_CLIENT_ID=your-client-id.apps.googleusercontent.com

GOOGLE_DESKTOP_CLIENT_SECRET=your-client-secret

Save it as apps/desktop/.env or at the repo root (already gitignored - never commit it). A repo-root .env using the server's GOOGLE_OAUTH_CLIENT_ID / GOOGLE_OAUTH_CLIENT_SECRET names works too, so one file can serve both the app and the MCP server. A packaged install reads .env from its data directory instead (%APPDATA% on Windows).

Your everyday launch afterwards is just:

cd samarth-analytics-mcp/apps/desktop && npm run dev

Full guide - Windows/macOS specifics, first-run setup, building a real .exe/.dmg installer, and the Error: Electron uninstall fix: apps/desktop/INSTALL.md.


Google Cloud OAuth Setup

Step 1: Enable the GTM API
  1. Go to Google Cloud Console
  2. Select or create a project
  3. Navigate to APIs & Services → Library
  4. Search for "Tag Manager API" and click Enable
  5. Search for "Google Analytics Admin API" and click Enable (required for the read-only ga4_* Admin tools)
  6. Search for "Google Analytics Data API" and click Enable (required for ga4_run_report / ga4_run_realtime_report)
Step 2: Create OAuth 2.0 Credentials
  1. Go to APIs & Services → Credentials
  2. Click Create Credentials → OAuth 2.0 Client ID
  3. Choose application type:
  • Desktop app — simplest for local stdio use (no redirect URI needed)
  • Web application — for the HTTP server (add your redirect URI)
  1. Download the JSON or copy the Client ID and Client Secret
  2. Add to .env:
   GOOGLE_CLIENT_ID=your-client-id.apps.googleusercontent.com

GOOGLE_CLIENT_SECRET=your-client-secret GOOGLE_REDIRECT_URI=http://localhost:3001/oauth/callback

Step 3: Configure OAuth Consent Screen
  1. Go to APIs & Services → OAuth consent screen
  2. Choose External (or Internal if you have Google Workspace)
  3. Fill in App name, support email
  4. Add scopes:
  • https://www.googleapis.com/auth/tagmanager.readonly
  • https://www.googleapis.com/auth/tagmanager.edit.containers
  • https://www.googleapis.com/auth/tagmanager.edit.containerversions
  • https://www.googleapis.com/auth/tagmanager.manage.accounts
  • https://www.googleapis.com/auth/tagmanager.manage.users
  • https://www.googleapis.com/auth/tagmanager.publish
  • https://www.googleapis.com/auth/analytics.readonly (read-only GA4 Admin and Data API tools)
  • https://www.googleapis.com/auth/analytics.edit (GA4 Admin write tools — gated by GA4_MCP_ENABLE_WRITES)
  • https://www.googleapis.com/auth/analytics.manage.users (GA4 access-binding write tools)
  1. Add your Google account as a test user (while the app is in "testing" mode)

Note: For personal/agency use, keeping the app in "Testing" mode is fine. You will need to re-authorize every 7 days unless you publish the app or get it verified.

Step 4: Run OAuth Setup
npm run auth:google

Or, if you prefer the older paste-the-code helper:

npm run oauth:setup

Service Account Limitations

Short version: Service accounts do NOT work with GTM by default. Use OAuth 2.0.

The Google Tag Manager API is a user-data API — it manages resources owned by individual Google accounts. Service accounts are not Google users and are not automatically granted access to GTM containers.

Option A: Add the service account as a GTM user (simplest)

If you still want to use a service account:

  1. Get the service account email (e.g., my-sa@project.iam.gserviceaccount.com)
  2. In GTM, go to Admin → User Management at the account or container level
  3. Add the service account email with the appropriate role (Read, Edit, Approve, Publish)
  4. Set GOOGLE_SERVICE_ACCOUNT_KEY_FILE=/path/to/key.json in .env

Caveats: This only works if the GTM container is associated with a Google account, not a Google Workspace that restricts external sharing.

Option B: Domain-Wide Delegation (Google Workspace only)

For Google Workspace organizations:

  1. Create a service account with a JSON key
  2. Enable Domain-Wide Delegation on the service account in Google Cloud Console
  3. In Google Workspace Admin Console → Security → API Controls → Domain-wide Delegation:
  • Add the service account client ID
  • Add scopes: https://www.googleapis.com/auth/tagmanager.edit.containers (and others as needed)
  1. In .env, set:
   GOOGLE_SERVICE_ACCOUNT_KEY_FILE=/path/to/key.json
  1. The server will impersonate the user automatically if you set a subject in buildGoogleAuth()

Caveats: Requires a paid Google Workspace account. Only available for your own domain.


Environment Variables Reference

VariableDefaultDescription
GOOGLE_OAUTH_CLIENT_ID—OAuth client ID (preferred). Falls back to GOOGLE_CLIENT_ID.
GOOGLE_OAUTH_CLIENT_SECRET—OAuth client secret (preferred). Falls back to GOOGLE_CLIENT_SECRET.
GOOGLE_OAUTH_REDIRECT_URIhttp://localhost:3001/oauth/callbackOAuth redirect URI. Falls back to GOOGLE_REDIRECT_URI.
GOOGLE_CLIENT_ID / GOOGLE_CLIENT_SECRET / GOOGLE_REDIRECT_URI—Legacy names, still supported.

| SAMARTH_GOOGLE_OAUTH_CLIENT_ID | — | Hosted-only. Samarth-owned public OAuth client. Takes precedence over the self-hosted va

Only the beginning is shown; read the rest in the repo