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 "Workspace" resource with the "Get Workspaces" operation enables users to retrieve information about workspaces belonging to a specific GTM container.

Common scenarios for this node include:

  • Automating the retrieval of workspace details for auditing or reporting.
  • Integrating GTM workspace data into broader marketing or analytics workflows.
  • Synchronizing workspace information with other systems or databases.

For example, a user might use this node to list all workspaces in a container to check their status before deploying changes or to monitor workspace activity over time.

Properties

Name Meaning
Account ID The unique identifier of the Google Tag Manager Account.
Container ID The unique identifier of the GTM Container within the account.
Workspace ID The unique identifier of the GTM Workspace (optional for some operations).
Optional Query Parameters Additional parameters to customize the API request. For example, pagination tokens or flags.

The optional query parameters collection includes various fields, but for the "Get Workspaces" operation, typically only relevant parameters like pageToken (for pagination) might be used.

Output

The output is a JSON array where each item corresponds to the response from the GTM API for the requested operation. For the "Get Workspaces" operation, the JSON structure represents one or more workspace objects containing details such as workspace name, description, path, and other metadata as defined by the GTM API.

No binary data is output by this node.

Dependencies

  • Requires an OAuth2 credential configured for Google Tag Manager API access.
  • The node uses the base URL https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the Google Tag Manager account are necessary to perform workspace queries.

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that a valid Google Tag Manager OAuth2 credential is set up in n8n.
  • Required Parameter Errors: The node validates required parameters such as Account ID and Container ID. Missing these will cause errors. Make sure these IDs are correctly provided.
  • API Errors: Errors returned from the GTM API (e.g., permission denied, invalid IDs) will be surfaced with messages prefixed by "Error calling GTM API". Check the message and stack trace for details.
  • Pagination Handling: When retrieving many workspaces, use the pageToken optional parameter to handle paginated results properly.

Links and References


This summary focuses on the "Workspace" resource and the "Get Workspaces" operation as requested, based on static analysis of the provided source code and property definitions.

Discussion