Open Source CLI Tool

Manage GTM from your terminal

GTM CLI is a powerful command-line interface that gives you complete control over Google Tag Manager. Perfect for automation, CI/CD pipelines, and power users who live in the terminal.

Built for AI agents.
JSON output that LLMs can parse and act on.
CI/CD ready.
Automate GTM as part of your deployment pipeline.
Full API coverage.
Tags, triggers, variables, versions, environments, and more.

Install & get started in seconds:

curl -fsSL https://raw.githubusercontent.com/owntag/gtm-cli/main/install.sh | bash
~/projects β€” gtm-cli
❯ gtm

  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ–ˆβ•—     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•—     β–ˆβ–ˆβ•—
 β–ˆβ–ˆβ•”β•β•β•β•β• β•šβ•β•β–ˆβ–ˆβ•”β•β•β•β–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘
 β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•”β–ˆβ–ˆβ–ˆβ–ˆβ•”β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘
 β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ•‘    β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ•‘
 β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•   β–ˆβ–ˆβ•‘   β–ˆβ–ˆβ•‘ β•šβ•β• β–ˆβ–ˆβ•‘    β•šβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘
  β•šβ•β•β•β•β•β•    β•šβ•β•   β•šβ•β•     β•šβ•β•     β•šβ•β•β•β•β•β•β•šβ•β•β•β•β•β•β•β•šβ•β•


πŸ€– AI/LLM agents: Run 'gtm agent guide' for a comprehensive usage guide.

Author:  owntag

Description:

  Command-line interface for Google Tag Manager

Commands:

  auth              Manage authentication
  containers        Manage GTM containers
  workspaces        Manage GTM workspaces
  tags              Manage GTM tags
  triggers          Manage GTM triggers
  variables         Manage GTM variables
  …

Why use GTM CLI?

Everything you need

GTM CLI brings the full power of Google Tag Manager to your terminal, with features designed for developers, analysts, and automation workflows.

Speed & Efficiency
Perform operations that would take minutes in the web UI in seconds. Batch operations and keyboard-driven workflows make you significantly faster.
AI batteries included
Instructions for AI agents and LLMs to use GTM CLI is already included, no need to write custom prompts.
Full API Coverage
Manage everything: accounts, containers, workspaces, tags, triggers, variables, versions, environments, folders, user permissions, and server-side GTM resources.
Flexible Authentication
Choose your preferred authentication method: OAuth for interactive use, or Service Accounts for automation.
Shell Completions
Built-in completion scripts for bash, zsh, and fish. Get intelligent tab completion for commands, flags, and arguments.
Multiple Output Formats
Choose between table, JSON, or compact output. Automatically uses JSON when piping to other tools for seamless integration.

Quick Start

1. Authenticate

# Interactive OAuth login (opens browser)
gtm auth login

# Or use a service account for automation
gtm auth login --service-account path/to/key.json

2. Set defaults (optional)

# Configure your default account/container
gtm config setup

3. Start managing your GTM

# List your accounts
gtm accounts list

# List containers in an account
gtm containers list --account-id 123456

# List all tags in a workspace
gtm tags list

# Get a specific tag
gtm tags get --tag-id 42

Common Use Cases

Managing Tags

# List all tags
gtm tags list

# Create a new tag
gtm tags create --name "GA4 Event" --type gaawe --config '{"parameter": [...]}'

# Update a tag
gtm tags update --tag-id 42 --name "New Name"

# Delete a tag
gtm tags delete --tag-id 42 --force

Version Control

# Create a new version
gtm versions create --name "v1.0" --notes "Initial release"

# Get the current live version
gtm versions live

# Publish a version
gtm versions publish --version-id 42

Workspace Management

# List workspaces
gtm workspaces list

# Create a new workspace
gtm workspaces create --name "Feature Branch"

# Check workspace status (pending changes)
gtm workspaces status --workspace-id 1

# Sync workspace with live version
gtm workspaces sync --workspace-id 1

Server-Side GTM

GTM CLI fully supports server-side GTM resources:

# Manage clients
gtm clients list
gtm clients create --name "GA4 Client" --type gaaw_client

# Manage templates
gtm templates list

# Manage transformations
gtm transformations list

Output Formats

GTM CLI adapts to your workflow:

# Table output (default for terminals)
gtm tags list --output table

# JSON output (default when piping)
gtm tags list --output json

# Compact output (just IDs and names)
gtm tags list --output compact

# Pipe to other tools
gtm tags list | jq '.[].name'

CI/CD Integration

GTM CLI shines in automated workflows. Here’s an example GitHub Actions workflow:

jobs:
  deploy-gtm:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        
      - name: Install GTM CLI
        run: |
          curl -fsSL https://raw.githubusercontent.com/owntag/gtm-cli/main/install.sh | bash
                    
      - name: Deploy to GTM
        env:
          GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.GTM_SERVICE_ACCOUNT_KEY }}
        run: |
          # Create and publish a new version
          gtm versions create --name "Deploy ${{ github.sha }}"
          gtm versions publish --version-id $(gtm version-headers list --output json | jq -r '.[0].containerVersionId')          

Questions or feedback? Open an issue on GitHub – we'd love to hear from you!

Privacy policy for GTM CLI

GTM CLI is a command-line interface for Google Tag Manager, developed and maintained by owntag GmbH (“we”, “us”, or “our”). This privacy policy explains how GTM CLI handles user data when you authenticate with Google.

Data Accessed

When you authenticate GTM CLI with your Google account, the application requests access to the following data:

Google Tag Manager Data:

  • Tag Manager account information
  • Container configurations
  • Workspaces, tags, triggers, and variables
  • Container versions and publishing settings
  • User permissions within Tag Manager

Google Account Information:

  • Your email address
  • Your display name

How Your Data Is Used

GTM CLI uses the accessed data exclusively to:

  • Execute commands you initiate against the Google Tag Manager API
  • Display your email and name in the CLI to confirm your authenticated identity
  • Authenticate API requests on your behalf

All operations are performed locally on your machine. GTM CLI acts as a client that communicates directly with Google’s APIs based on your commands.

Data Sharing

GTM CLI does not share your data with any third parties.

  • No user data is transmitted to owntag GmbH or any other party
  • No analytics or telemetry data is collected
  • No usage data is tracked or reported
  • All network communication occurs exclusively between your local machine and Google’s official APIs

Data Storage and Protection

GTM CLI stores authentication credentials locally on your machine:

  • Location: ~/.config/gtm-cli/credentials.json (Linux/macOS) or the equivalent application data directory on your operating system
  • Contents: OAuth access token, refresh token, token expiration time, and basic profile information (email, name)
  • Protection: Credential files are created with restrictive file permissions (readable only by your user account)

No data is stored on external servers. All credentials remain exclusively on your local device.

Data Retention and Deletion

Retention: Authentication credentials are retained locally until you explicitly sign out or manually delete them.

Deletion: You can delete all stored data at any time by:

  1. Running the logout command:

    gtm auth logout
    

    This revokes your tokens with Google and deletes all locally stored credentials.

  2. Alternatively, manually deleting the configuration directory:

    rm -rf ~/.config/gtm-cli
    

Upon logout, GTM CLI also requests that Google revoke the issued tokens, ensuring your authorization is fully terminated.

Open Source Transparency

GTM CLI is open source software. You can review exactly how your data is handled by examining the source code at:

https://github.com/owntag/gtm-cli

Contact

If you have questions about this privacy policy or GTM CLI’s data practices, please get in touch through the contact information provided in our Impressum.

Become a Server Side Tagging Pro with owntag

Take control of your digital data collection with Server Side Tagging and Server Side GTM – easily hosted with owntag.

App screenshot