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, enabling users to manage various GTM resources programmatically within n8n workflows. Specifically, for the Transformation resource and the Create Transformation operation, it allows users to create a new transformation entity inside a specified GTM container workspace.

Use cases include automating the creation of transformations in GTM to modify or manipulate data layers or tags dynamically without manual intervention in the GTM UI. This is beneficial for teams managing multiple GTM containers or workspaces who want to streamline their tag management processes.

Example: Automatically creating a transformation when a new marketing campaign starts, ensuring that data is transformed according to campaign-specific rules.

Properties

Name Meaning
Account ID The GTM Account ID where the transformation will be created.
Container ID The GTM Container ID within the account where the transformation will be created.
Workspace ID The GTM Workspace ID inside the container where the transformation will be created.
Optional Query Parameters Additional optional parameters for the API request, such as flags or filters (not typically used for creation).
Request Body JSON object representing the details of the transformation to create. This should follow the GTM API's expected schema for a transformation resource.

Output

The node outputs an array of JSON objects representing the response from the GTM API after creating the transformation. The output JSON structure corresponds to the newly created transformation resource, including its unique identifiers, configuration, and metadata as returned by the GTM API.

No binary data is output by this node.

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 the Google Tag Manager API OAuth2 credentials are properly set up in n8n.
  • Required Parameter Errors: The node validates required parameters like Account ID, Container ID, and Workspace ID. Missing any of these will cause an error. Double-check that these IDs are correctly provided.
  • API Errors: Errors returned from the GTM API (e.g., invalid request body, permission issues) will be surfaced with messages prefixed by "Error calling GTM API". Review the message and stack trace for details.
  • Invalid JSON in Request Body: Ensure the JSON provided in the Request Body property is well-formed and matches the expected GTM transformation schema.

Links and References

Discussion