Google Tag Manager icon

Google Tag Manager

Use the Google Tag Manager API

Actions84

Overview

This node integrates with the Google Tag Manager (GTM) API, enabling users to manage various GTM resources programmatically within n8n workflows. It supports a wide range of operations across multiple GTM resource types such as accounts, containers, tags, triggers, variables, workspaces, environments, folders, user permissions, and more.

Common scenarios where this node is beneficial include automating GTM container management, synchronizing tag configurations, managing user permissions, creating or updating GTM entities, and retrieving GTM data for reporting or auditing purposes.

For example:

  • Automatically create and configure new GTM containers or tags when launching new websites.
  • List all GTM accounts or containers accessible to a user for inventory or monitoring.
  • Update workspace entities or publish container versions as part of a CI/CD pipeline.
  • Manage user permissions dynamically based on organizational changes.

Properties

Name Meaning
Optional Query Parameters A collection of optional parameters that can be added to the API request. Includes options like:
- Allow User Permission Feature Update (boolean)
- Built-In Variable Type (many predefined options like Advertiser ID, AMP Client ID, etc.)
- Container ID
- Container Version ID
- Copy Settings (boolean)
- Copy Terms Of Service (boolean)
- Copy Users (boolean)
- Destination ID
- Fingerprint
- Include Google Tags (boolean)
- Page Token (string, password type)
- Setting Source (options: Current, Other, Unspecified)
- Tag ID
- Tag Name
- Trigger ID
- Variable ID
Account ID The GTM Account ID relevant to the operation. Required for most operations involving account-specific resources.
Container ID The GTM Container ID relevant to the operation. Required for many container-scoped operations.
Workspace ID The GTM Workspace ID used in workspace-related operations.
Client ID GTM Client ID, required for client-specific operations.
Destination Link ID Google Tag Destination Link ID, required for destination-specific operations.
Environment ID GTM Environment ID, required for environment-specific operations.
Folder ID GTM Folder ID, required for folder-specific operations.
Google Tag Configuration ID ID for Google Tag Configuration, used in related operations.
Tag ID GTM Tag ID, required for tag-specific operations.
Template ID GTM Template ID, required for template-specific operations.
Transformation ID GTM Transformation ID, required for transformation-specific operations.
Trigger ID GTM Trigger ID, required for trigger-specific operations.
User Permissions ID GTM User Permissions ID, required for user permission-specific operations.
Variable ID GTM Variable ID, required for variable-specific operations.
Version ID GTM Version ID, required for version-specific operations.
Zone ID GTM Zone ID, required for zone-specific operations.
Request Body JSON object representing the body of the request for operations that require sending data (e.g., create, update).

The Operation and Resource properties (not listed here but part of the node configuration) determine which specific GTM API endpoint and action will be executed.

Output

The node outputs an array of JSON objects corresponding to the responses from the Google Tag Manager API calls made during execution. Each item in the output array represents the parsed JSON response from one API call.

The structure of the output JSON depends on the specific GTM resource and operation invoked. For example:

  • Listing accounts returns an array of account objects.
  • Getting a tag returns the tag's detailed configuration.
  • Creating or updating resources returns the created/updated resource representation.

No binary data output is produced by this node.

Dependencies

  • Requires valid Google Tag Manager API credentials configured in n8n using OAuth2 authentication.
  • The node uses the Google Tag Manager REST API v2 endpoint: https://www.googleapis.com/tagmanager/v2.
  • Proper OAuth2 credentials must be set up and authorized to access the GTM account(s).

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that the Google Tag Manager OAuth2 credential is properly configured and connected.
  • Required Parameter Errors: Many operations require specific IDs (Account ID, Container ID, Workspace ID, etc.). Missing these will cause errors indicating which parameter is required. Provide all necessary IDs for the chosen operation.
  • Unknown Operation Error: If an unsupported or misspelled operation is selected, the node will throw an "Unknown operation" error. Verify the operation name matches one of the supported options.
  • API Call Failures: Errors returned from the GTM API (e.g., permission denied, invalid parameters) are wrapped and reported with the message prefix "Error calling GTM API". Check the error details for specifics.
  • Optional Query Parameters: Incorrect or incompatible optional query parameters may cause API failures. Use them only as documented and appropriate for the operation.

Links and References

Discussion