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 "Update Trigger" operation under the "Trigger" resource enables updating an existing GTM trigger in a specified workspace and container.

Use cases include automating the management of GTM triggers such as modifying trigger conditions or configurations without manually accessing the GTM web interface. This is beneficial for teams managing multiple GTM containers or automating deployment pipelines.

Example scenario: Automatically update a trigger's configuration when a new marketing campaign starts, ensuring that tags fire correctly based on updated criteria.

Properties

Name Meaning
Account ID The unique identifier of the Google Tag Manager account where the trigger resides.
Container ID The identifier of the GTM container within the account that holds the trigger.
Workspace ID The workspace ID inside the container where the trigger exists.
Trigger ID The specific ID of the trigger to be updated.
Optional Query Parameters Additional optional parameters to customize the request. These include:
- Allow User Permission Feature Update (boolean): Allows user permissions feature update.
- Built-In Variable Type (select from many predefined types).
- Container ID, Container Version ID, Copy Settings, Copy Terms Of Service, Copy Users, Destination ID, Fingerprint, Include Google Tags, Page Token, Setting Source, Tag ID, Tag Name, Trigger ID, Variable ID (various types and purposes related to GTM entities).
Request Body JSON object containing the data to update the trigger with. This should follow the GTM API's expected structure for a trigger resource update.

Output

The node outputs the JSON response returned by the Google Tag Manager API after performing the update operation. This JSON represents the updated trigger resource, including all its properties as stored in GTM after the update.

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.

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that a valid Google Tag Manager OAuth2 credential is set up and connected.
  • Required Parameter Errors: The node validates required parameters like Account ID, Container ID, Workspace ID, and Trigger ID. Missing any of these will cause an error. Double-check that these IDs are correctly provided.
  • API Call Failures: Errors returned from the GTM API (e.g., invalid JSON in the request body, permission issues) will be surfaced with messages prefixed by "Error calling GTM API". Review the message and stack trace for details.
  • Invalid Request Body: Ensure the JSON in the Request Body property matches the expected schema for a GTM trigger update; otherwise, the API may reject the request.

Links and References

Discussion