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, specifically enabling management of GTM Built-In Variables among many other GTM resources. The "List Built-In Variables" operation retrieves all enabled built-in variables within a specified GTM Container Workspace.

Common scenarios for this node include:

  • Automating retrieval of built-in variables to audit or synchronize GTM configurations.
  • Integrating GTM data into workflows for reporting or further processing.
  • Managing GTM environments programmatically without manual intervention in the GTM UI.

For example, a user can list all enabled built-in variables in a particular workspace to verify which variables are active before deploying tags or triggers.

Properties

Name Meaning
Account ID The GTM Account ID where the container resides.
Container ID The GTM Container ID containing the workspace.
Workspace ID The GTM Workspace ID within the container.
Optional Query Parameters Additional optional parameters for the API call:
- Allow User Permission Feature Update Boolean flag to allow user permission feature updates (default true).
- Built-In Variable Type Filter by type of built-in variable; many options such as Advertiser ID, Click URL, Event, etc.
- Container ID ID of a container to merge (used in some operations, not relevant here).
- Container Version ID Specific container version ID (not required for listing built-in variables).
- Copy Settings Whether to copy tag settings (not relevant here).
- Copy Terms Of Service Acceptance of terms of service agreements (not relevant here).
- Copy Users Whether to copy users (not relevant here).
- Destination ID Destination linked to a GTM container (not relevant here).
- Fingerprint Fingerprint for concurrency control (not relevant here).
- Include Google Tags Whether to include accounts associated with Google Tag (not relevant here).
- Page Token Token for pagination to fetch next page results.
- Setting Source Source of config setting after combine (not relevant here).
- Tag ID Tag ID for GTM container (not relevant here).
- Tag Name Name for newly created tag (not relevant here).
- Trigger ID Trigger ID to move to folder (not relevant here).
- Variable ID Variable ID to move to folder (not relevant here).

Note: For the "List Built-In Variables" operation, the key required properties are Account ID, Container ID, and Workspace ID. Optional query parameters like filtering by built-in variable type and pagination token can be used.

Output

The output is a JSON array where each item represents a built-in variable object retrieved from the GTM API. Each object contains details about an enabled built-in variable in the specified workspace, such as its type, name, and configuration.

Example structure of one built-in variable item (simplified):

{
  "name": "accounts/{accountId}/containers/{containerId}/workspaces/{workspaceId}/built_in_variables/{variableId}",
  "type": "clickUrl",
  "parameter": [...],
  "fingerprint": "abc123"
}

The exact fields depend on the GTM API response but generally include identifiers, variable type, and metadata.

No binary data output is involved.

Dependencies

  • Requires a valid Google Tag Manager API OAuth2 credential configured in n8n.
  • The node uses the Google Tag Manager v2 REST API endpoint: https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account to read built-in variables are necessary.

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that a valid Google Tag Manager OAuth2 API credential is set up in n8n.
  • Required Parameter Missing: Errors indicating missing Account ID, Container ID, or Workspace ID mean these must be provided for the operation to succeed.
  • API Rate Limits or Permissions: If the API returns errors related to permissions or rate limits, verify that the authenticated user has access to the specified GTM account and container, and check quota usage.
  • Unknown Operation Error: This indicates an invalid operation parameter; ensure "List Built-In Variables" is selected correctly.
  • Pagination Handling: If there are many built-in variables, use the "Page Token" optional parameter to paginate through results.

Links and References

Discussion