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 "Variable" resource and the "List Variables" operation, it retrieves a list of all variables defined in a specified GTM container workspace.

Common scenarios where this node is beneficial include:

  • Automating the retrieval of GTM variables for auditing or reporting purposes.
  • Integrating GTM variable data into other systems or workflows.
  • Synchronizing GTM variables across environments or accounts.

For example, a user might use this node to fetch all variables from a particular GTM workspace and then process or export them to a spreadsheet or database automatically.

Properties

Name Meaning
Account ID The unique identifier of the Google Tag Manager account containing the container.
Container ID The unique identifier of the GTM container where variables are managed.
Workspace ID The identifier of the GTM workspace within the container where variables reside.
Optional Query Parameters Additional optional parameters to refine or control the API request.

The Optional Query Parameters collection can include:

  • allowUserPermissionFeatureUpdate (boolean): Allows updating user permission features if set to true.
  • type (options): Filters by built-in variable type (e.g., Advertiser ID, Click URL, Page Path, etc.).
  • pageToken (string): Token for pagination to fetch the next page of results.
  • Other parameters related to GTM operations, but typically not required for listing variables.

Output

The output is a JSON array where each item represents a GTM variable retrieved from the specified container workspace. Each variable object contains details as returned by the GTM API, such as variable name, type, parameter values, and metadata.

No binary data is output by this operation.

Example output structure snippet (simplified):

[
  {
    "name": "accounts/{accountId}/containers/{containerId}/workspaces/{workspaceId}/variables/{variableId}",
    "parameter": [...],
    "type": "jsm",
    "notes": "...",
    "fingerprint": "...",
    ...
  },
  ...
]

Dependencies

  • Requires an active Google Tag Manager API OAuth2 credential configured in n8n.
  • The node uses the Google Tag Manager API v2 endpoint: https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account to list variables are necessary.

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that a valid Google Tag Manager API OAuth2 credential is configured and selected.
  • Required Parameter Errors: The node requires Account ID, Container ID, and Workspace ID to be provided. Omitting any of these will cause an error indicating which ID is missing.
  • API Rate Limits or Permissions: If the API returns errors related to rate limits or insufficient permissions, verify the OAuth2 token scopes and GTM account access rights.
  • Unknown Operation Error: This should not occur if the operation is correctly set to "List Variables". If it does, check the node configuration.

Links and References


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

Discussion