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!