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, the "Revert Template" operation under the "Template" resource enables reverting changes made to a GTM Custom Template in a specified workspace back to its previous state.

Common scenarios for this operation include:

  • Undoing unintended or erroneous modifications to a custom template during workspace development.
  • Quickly restoring a template to a known good version without manually navigating the GTM interface.
  • Automating rollback procedures as part of deployment pipelines or error recovery workflows.

Example use case:
A marketing team is testing new tag templates in a GTM workspace. If a change causes issues, they can trigger this node to revert the template to its last stable version automatically, ensuring consistent tag behavior on their website.

Properties

Name Meaning
Account ID The GTM Account ID where the template resides.
Container ID The GTM Container ID that contains the workspace and template.
Workspace ID The GTM Workspace ID within the container where the template exists.
Template ID The specific GTM Template ID to revert.
Optional Query Parameters Additional optional parameters for the API call. For this operation, typically empty or unused.

Output

The output is a JSON array containing the response from the GTM API after reverting the template. This response includes the reverted template's details such as its current configuration and metadata reflecting the rollback.

No binary data is involved in this operation.

Dependencies

  • Requires an active Google Tag Manager API OAuth2 credential configured in n8n.
  • The node makes authenticated HTTP requests to the Google Tag Manager API endpoint: https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account, container, and workspace are necessary to perform revert operations.

Troubleshooting

  • Missing Required IDs: Errors will occur if any of the required IDs (Account ID, Container ID, Workspace ID, Template ID) are not provided. Ensure all these fields are correctly filled.
  • Authentication Errors: If the OAuth2 credentials are missing or invalid, the node will throw an authentication error. Verify the credential setup and refresh tokens if needed.
  • Permission Denied: Insufficient user permissions on the GTM account or workspace may cause failures. Confirm that the authenticated user has edit rights.
  • Unknown Operation Error: If the operation parameter is incorrect or unsupported, the node will report an unknown operation error.
  • API Rate Limits: Frequent revert calls might hit Google API rate limits; handle retries or backoff accordingly.

Links and References

Discussion