Google Tag Manager icon

Google Tag Manager

Use the Google Tag Manager API

Actions84

Overview

The node integrates with the Google Tag Manager (GTM) API, specifically enabling management of GTM resources. For the Template resource and the Update Template operation, it allows users to update an existing custom template within a specified GTM workspace. This is useful for automating updates to GTM templates programmatically, such as modifying tag templates or custom variables in your container workspaces.

Common scenarios include:

  • Automating template updates during deployment pipelines.
  • Managing GTM templates across multiple containers or accounts.
  • Integrating GTM template updates into broader marketing or analytics workflows.

Example: You have a custom tag template that needs a configuration change; this node can update the template directly via the API without manual intervention in the GTM UI.

Properties

Name Meaning
Account ID The GTM Account ID where the template resides.
Container ID The GTM Container ID containing the workspace with the template.
Workspace ID The GTM Workspace ID where the template exists and will be updated.
Template ID The ID of the GTM Template to update.
Optional Query Parameters Additional optional parameters for the API call (e.g., allowUserPermissionFeatureUpdate).
Request Body JSON object representing the updated template data to send in the request body.

Details on Optional Query Parameters (subset relevant to update):

  • allowUserPermissionFeatureUpdate (boolean): Must be true to allow user permission features to update.
  • Other parameters exist but are generally not required for template update.

Output

The node outputs the JSON response from the Google Tag Manager API after updating the template. This JSON contains the updated template's details as returned by the API, including its metadata and configuration.

The output structure corresponds to the GTM Template resource representation, typically including fields like:

  • Template ID
  • Name
  • Parameter definitions
  • Fingerprint (for concurrency control)
  • Other template-specific properties

No binary data output is involved.

Dependencies

  • Requires valid Google Tag Manager API credentials configured in n8n (an OAuth2 API credential).
  • Internet access to call the Google Tag Manager API endpoint at https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account to update templates.

Troubleshooting

  • Missing Credentials Error: If the node throws "Missing Google Tag Manager API Credentials," ensure you have set up and selected valid OAuth2 credentials for Google Tag Manager.
  • Required Parameter Errors: Errors like "GTM Account ID is required" or "GTM Template ID is required" indicate missing mandatory inputs. Verify all required IDs are provided.
  • API Errors: Errors returned from the GTM API (e.g., permission denied, invalid template data) will be surfaced with messages prefixed by "Error calling GTM API." Check the error message and stack trace for details.
  • Concurrency Issues: The API uses fingerprints for concurrency control. If you get errors related to fingerprint mismatch, ensure you provide the correct fingerprint in the request body or fetch the latest template version before updating.

Links and References


This summary focuses on the Template resource's Update operation as requested, based on static analysis of the node's source code and provided property definitions.

Discussion