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, 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 deployment of tracking codes, marketing pixels, or custom scripts without manual intervention in the GTM web interface.

Typical use cases include:

  • Automatically creating new tags when deploying new marketing campaigns.
  • Managing tags programmatically as part of CI/CD pipelines for websites.
  • Bulk creation or templating of tags based on dynamic input data.

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 and other advanced options.
Request Body JSON object representing the tag configuration details to be created in GTM.

Details on Optional Query Parameters (selected examples):

  • 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 accounts associated with Google Tag.
  • tagName: The name for the newly created tag.

The full list of optional query parameters includes many more fields that control various aspects of tag creation and linking.

Output

The output is a JSON array containing the response from the Google Tag Manager API after creating the tag(s). Each element corresponds to one created tag and contains all properties returned by the GTM API for a tag resource, including its ID, name, type, firing triggers, and other configuration details.

No binary data output is involved.

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 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 details. 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.
  • Fingerprint Mismatch: If using the fingerprint parameter, ensure it matches the current stored fingerprint to avoid concurrency conflicts.
  • Terms of Service Acceptance: When copying terms of service, the corresponding flag must be set to true, or the operation will fail.

Links and References


This summary focuses on the "Create Tags" operation of the "Tag" resource, describing how to configure and use this node functionality effectively.

Discussion