Google Tag Manager icon

Google Tag Manager

Use the Google Tag Manager API

Actions102

Overview

This node integrates with the Google Tag Manager (GTM) API, allowing users to manage various GTM resources programmatically within n8n workflows. Specifically, the "Version" resource's "Live Version" operation retrieves the currently published (live) container version for a specified GTM account and container.

Common scenarios where this node is beneficial include:

  • Automating retrieval of the live container version to verify deployment status.
  • Integrating GTM version information into reporting or monitoring workflows.
  • Triggering downstream processes based on the live version details.

For example, a marketing automation workflow might use this node to fetch the live GTM container version before deploying new tags or triggers, ensuring synchronization between environments.

Properties

Name Meaning
Account ID The unique identifier of the Google Tag Manager Account from which to retrieve the live version.
Container ID The unique identifier of the GTM Container within the specified account.
Optional Query Parameters Additional optional parameters to customize the API request. For this operation, typically empty or unused.

Output

The node outputs a JSON object representing the live (published) container version of the specified GTM container. This JSON includes details such as version number, description, creation time, and other metadata related to the container version.

The output structure corresponds directly to the GTM API's response for the live container version endpoint. It does not produce binary data.

Example output snippet (simplified):

{
  "containerVersionId": "5",
  "name": "Live Version",
  "description": "Published version",
  "fingerprint": "abc123",
  "container": {
    "accountId": "123456",
    "containerId": "654321"
  },
  "createdTimestamp": "2023-01-01T12:00:00Z",
  ...
}

Dependencies

  • Requires an OAuth2 credential configured in n8n for authenticating with the Google Tag Manager API.
  • The node uses the base URL https://www.googleapis.com/tagmanager/v2.
  • No additional external dependencies are required beyond the configured API credentials.

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that a valid Google Tag Manager OAuth2 credential is configured and selected.
  • Required Parameter Errors: The node requires both Account ID and Container ID to be provided. Omitting either will cause an error indicating the missing parameter.
  • API Request Failures: Errors returned by the GTM API (e.g., permission denied, invalid IDs) will be surfaced with messages prefixed by "Error calling GTM API". Verify that the account and container IDs are correct and that the authenticated user has sufficient permissions.
  • Unknown Operation Error: This should not occur if the node is used correctly, but indicates an unsupported or misspelled operation name.

Links and References

Discussion