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. Specifically, for the Template resource and the List Templates operation, it lists all GTM Custom Templates within a specified GTM container workspace.

This functionality is useful when you want to retrieve all custom templates defined in a particular workspace of your GTM container, for example, to audit, report, or automate further processing based on these templates.

Practical Example

  • You have multiple custom templates in your GTM workspace and want to fetch their details automatically.
  • You want to build an automation that triggers when new templates are added or existing ones are updated.
  • You need to export or synchronize template configurations across different environments or accounts.

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 where templates exist.
Optional Query Parameters Additional optional parameters to customize the request. For this operation, typically empty.

Note: For the "List Templates" operation, the Account ID, Container ID, and Workspace ID are required to specify the scope from which to list templates.

Output

The output is a JSON array where each item represents a GTM Template object retrieved from the specified workspace. Each template object contains details such as its ID, name, description, and other metadata as provided by the GTM API.

The exact structure follows the Google Tag Manager API's Template representation, including fields like:

  • templateId: Unique identifier of the template.
  • name: Name of the template.
  • description: Description of the template.
  • Other configuration details relevant to the template.

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 v2 endpoint: https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account, container, and workspace are necessary to list templates.

Troubleshooting

  • Missing Required IDs: If Account ID, Container ID, or Workspace ID is not provided, the node will throw an error indicating the missing parameter.
  • Authentication Errors: Ensure that the OAuth2 credentials are correctly set up and authorized to access the GTM API.
  • Permission Denied: The authenticated user must have sufficient permissions on the GTM account and container to list templates.
  • API Rate Limits: Be aware of Google API rate limits; excessive requests may result in temporary blocking.
  • Unknown Operation Error: If the operation name is incorrect or unsupported, the node will throw an "Unknown operation" error.

Links and References


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

Discussion