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, for the Trigger resource and the Delete Trigger operation, it enables deleting a specific trigger from a GTM workspace.

Common scenarios where this node is beneficial include automating GTM container management tasks such as creating, updating, or deleting triggers without manual intervention in the GTM web interface. For example, you might automate cleanup of unused triggers or integrate GTM trigger management into a larger deployment pipeline.

Practical example: Automatically delete a trigger identified by its ID from a specified GTM account, container, and workspace when certain conditions are met in your workflow.

Properties

Name Meaning
Account ID The unique identifier of the Google Tag Manager Account where the trigger exists.
Container ID The unique identifier of the GTM Container within the account.
Workspace ID The unique identifier of the GTM Workspace inside the container.
Trigger ID The unique identifier of the GTM Trigger to be deleted.
Optional Query Parameters Additional optional parameters that can modify the request behavior (e.g., feature flags).

Output

The output is a JSON array containing the response from the Google Tag Manager API after attempting to delete the specified trigger. Typically, a successful delete operation returns an empty object {} or confirmation details depending on the API's response.

No binary data is output by this operation.

Dependencies

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

Troubleshooting

  • Missing Required IDs: If any of the required IDs (Account ID, Container ID, Workspace ID, Trigger ID) are missing, the node will throw an error indicating which ID is required.
  • Authentication Errors: Ensure the OAuth2 credentials are correctly set up and authorized for GTM API access.
  • Permission Denied: The authenticated user must have sufficient permissions to delete triggers in the specified GTM workspace.
  • Unknown Operation Error: If the operation parameter is incorrect or unsupported, the node will throw an "Unknown operation" error.
  • API Errors: Any errors returned by the GTM API (e.g., invalid IDs, network issues) will be wrapped and reported with the message prefix "Error calling GTM API".

To resolve these issues:

  • Double-check all required input fields.
  • Verify OAuth2 credentials and scopes.
  • Confirm user permissions in GTM.
  • Review the exact error message for API-specific issues.

Links and References

Discussion