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, the "Link Destination" operation under the "Destination" resource allows you to add a destination to a GTM Container and remove it from any container it is currently linked to. This is useful for managing how data destinations are associated with your GTM containers, facilitating dynamic updates to your tag management setup.

Common scenarios include:

  • Automating the linking of destinations to specific GTM containers as part of deployment pipelines.
  • Managing GTM configurations across multiple environments or accounts without manual intervention.
  • Streamlining container setup by programmatically adjusting destination links based on workflow logic.

Example: Automatically link a new advertising destination to a container when a campaign starts, ensuring tracking data flows correctly without manual configuration.

Properties

Name Meaning
Account ID The GTM Account ID where the container and destination reside.
Container ID The GTM Container ID to which the destination will be linked.
Optional Query Parameters Additional optional parameters to customize the request. Options include:
- Allow User Permission Feature Update (boolean)
- Built-In Variable Type (many predefined options)
- Container ID
- Container Version ID
- Copy Settings (boolean)
- Copy Terms Of Service (boolean)
- Copy Users (boolean)
- Destination ID (string)
- Fingerprint (string)
- Include Google Tags (boolean)
- Page Token (string)
- Setting Source (Current, Other, Unspecified)
- Tag ID (string)
- Tag Name (string)
- Trigger ID (string)
- Variable ID (string)

Note: For this operation, the key properties are Account ID, Container ID, and optionally parameters in the collection to control behavior.

Output

The node outputs a JSON array containing the response from the Google Tag Manager API for the "Link Destination" operation. The structure corresponds to the linked destination resource as returned by the GTM API, typically including details such as:

  • Destination identifiers and metadata.
  • Link status and related container information.

No binary data output is involved.

Dependencies

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

Troubleshooting

  • Missing Credentials Error: If the node throws an error about missing credentials, ensure that a valid Google Tag Manager OAuth2 credential is configured in n8n.
  • Required Parameter Errors: The node validates required parameters like Account ID and Container ID. Missing these will cause errors; verify all required fields are set.
  • API Errors: Errors returned from the GTM API (e.g., permission denied, invalid IDs) will be surfaced with messages prefixed by "Error calling GTM API". Check the provided IDs and user permissions.
  • Operation Unknown: If an unsupported operation is selected, the node will throw an "Unknown operation" error. Confirm the operation name matches supported values.

Links and References


This summary focuses on the "Link Destination" operation of the "Destination" resource, describing its purpose, inputs, outputs, dependencies, and common troubleshooting points based on static analysis of the provided source code and property definitions.

Discussion