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, specifically enabling management of GTM Tags among many other resources. The "Create Tags" operation under the "Tag" resource allows users to create new tags within a specified GTM workspace. This is useful for automating tag creation in GTM containers, which can help streamline marketing and analytics workflows by programmatically managing tracking tags.

Typical use cases include:

  • Automatically creating new tracking tags when deploying new campaigns.
  • Managing tags across multiple GTM accounts or containers without manual intervention.
  • Integrating GTM tag creation into broader automation workflows that involve data collection or event tracking.

Properties

Name Meaning
Account ID The GTM Account ID where the tag will be created.
Container ID The GTM Container ID within the account where the tag will be created.
Workspace ID The GTM Workspace ID inside the container where the tag will be created.
Optional Query Parameters Additional optional parameters for the API request, such as flags controlling user permission updates, copying settings, terms of service acceptance, etc.
Request Body JSON object representing the tag configuration details to be created in GTM.

Details on Optional Query Parameters (selected relevant ones):

  • allowUserPermissionFeatureUpdate: Boolean flag to allow updating user permissions feature.
  • copySettings: Whether to copy tag settings from an existing tag.
  • copyTermsOfService: Must be true to accept terms of service agreements copied from current tag.
  • copyUsers: Whether to copy users from the existing tag.
  • destinationId / tagId: IDs related to linking or specifying tags/destinations.
  • fingerprint: Used for concurrency control; must match stored fingerprint.
  • includeGoogleTags: Whether to include Google Tags associated with accounts.
  • pageToken: For pagination if applicable.
  • settingSource: Source of config setting after combining containers.

Output

The output is a JSON array containing the response from the Google Tag Manager API for each input item processed. For the "Create Tags" operation, this will typically be the newly created tag's full resource representation as returned by the GTM API, including its ID, name, type, parameters, and other metadata.

No binary data output is involved in this operation.

Dependencies

  • Requires valid Google Tag Manager API credentials configured in n8n using OAuth2 authentication.
  • The node makes HTTP requests to the GTM API endpoint at https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account and workspace are necessary to create tags.

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 Errors: The node validates required parameters like Account ID, Container ID, Workspace ID, and Tag ID (if applicable). Missing any of these will cause errors. Double-check that all required IDs are provided.
  • API Errors: Errors returned from the GTM API (e.g., permission denied, invalid request body) will be surfaced with messages prefixed by "Error calling GTM API". Review the message and stack trace for details.
  • Terms of Service Acceptance: When copying tags, the copyTermsOfService parameter must be set to true to avoid operation failure.
  • Concurrency Issues: If using the fingerprint parameter, ensure it matches the current stored fingerprint to prevent update conflicts.

Links and References


This summary focuses on the "Create Tags" operation under the "Tag" resource, describing how to configure and use the node to create GTM tags programmatically.

Discussion