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 "Delete Template" operation under the "Template" resource enables users to delete a custom template from a specified GTM workspace.

Common scenarios for this node include automating GTM workspace management tasks such as creating, updating, or deleting templates, tags, triggers, and other GTM entities. For example, a marketing team might automate the cleanup of unused templates in their GTM container workspaces to maintain an organized environment.

Practical example: Automatically delete obsolete GTM templates when a campaign ends by triggering this node with the appropriate account, container, workspace, and template IDs.

Properties

Name Meaning
Account ID The GTM Account ID where the template resides.
Container ID The GTM Container ID within the account.
Workspace ID The GTM Workspace ID inside the container where the template exists.
Template ID The specific GTM Template ID to be deleted.
Optional Query Parameters Additional optional parameters that can modify the request behavior (see below).

Optional Query Parameters (subset relevant to Delete Template)

  • allowUserPermissionFeatureUpdate (boolean): Whether to allow user permission feature updates during the operation.
  • fingerprint (string): A fingerprint value that must match the stored account fingerprint to proceed.
  • Other parameters exist but are generally not applicable to the delete template operation.

Output

The node outputs a JSON array containing the parsed response from the GTM API after the delete operation. Typically, a successful delete operation returns an empty object {} or confirmation details depending on the API's response.

No binary data output is involved in this operation.

Dependencies

  • Requires valid Google Tag Manager API credentials configured in n8n (an OAuth2 API credential).
  • The node uses the official GTM API endpoint: https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account and workspace are necessary to perform deletion.

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that the Google Tag Manager OAuth2 API credentials are properly set up in n8n.
  • Required Parameter Missing: Errors indicating missing Account ID, Container ID, Workspace ID, or Template ID mean these fields must be provided for the operation to succeed.
  • Permission Denied: If the API returns permission errors, verify that the authenticated user has sufficient rights to delete templates in the specified GTM workspace.
  • Fingerprint Mismatch: If using the optional fingerprint parameter, ensure it matches the current fingerprint of the account; otherwise, the operation will fail.
  • Unknown Operation: This node only supports predefined operations; ensure the operation name is correctly set to "templatesDelete" for deleting templates.

Links and References


If you need details on other operations or resources, feel free to ask!

Discussion