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, allowing users to manage various GTM resources programmatically within n8n workflows. Specifically, for the Environment resource and the List Environments operation, it retrieves a list of all environments associated with a specified GTM container.

Common scenarios where this node is beneficial include:

  • Automating the retrieval of environment configurations for auditing or reporting.
  • Integrating GTM environment data into broader marketing or analytics workflows.
  • Synchronizing environment information across multiple systems or teams.

For example, a user might want to fetch all environments in a container to verify deployment stages (e.g., live, staging) before triggering further automation steps.

Properties

Name Meaning
Account ID The unique identifier of the GTM Account containing the container.
Container ID The unique identifier of the GTM Container whose environments are to be listed.
Optional Query Parameters Additional optional parameters to refine the request. For this operation, typically unused.

Details on properties relevant to "Environment - List Environments":

  • Account ID: Required to specify which GTM account to query.
  • Container ID: Required to specify which container's environments to list.
  • Optional Query Parameters: A collection of optional parameters that can be added if needed, but generally not required for listing environments.

Output

The output is a JSON array where each item represents an environment object retrieved from the GTM API. Each environment object contains details such as environment name, URL, authorization codes, and other metadata defined by GTM.

The structure corresponds directly to the Google Tag Manager Environment resource representation, including fields like:

  • name: The environment's display name.
  • url: The URL associated with the environment.
  • Other environment-specific configuration details.

No binary data is output by this operation.

Dependencies

  • Requires valid Google Tag Manager API credentials configured in n8n using OAuth2 authentication.
  • The node uses the Google Tag Manager API endpoint at https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account and container are necessary to list environments.

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that the Google Tag Manager OAuth2 API credentials are properly set up in n8n.
  • Required Parameter Errors: Errors indicating missing Account ID or Container ID mean these inputs were not provided; both are mandatory for this operation.
  • API Errors: Any errors returned from the GTM API will be surfaced with messages prefixed by "Error calling GTM API". Check the message for details such as permission issues or invalid IDs.
  • Pagination: If many environments exist, consider handling pagination via the optional pageToken parameter in optional query parameters (not commonly needed for environments).

Links and References


This summary focuses on the "Environment" resource and the "List Environments" operation as requested, based on static analysis of the provided source code and property definitions.

Discussion