Google Tag Manager icon

Google Tag Manager

Use the Google Tag Manager API

Actions84

Overview

The "Link Destination" operation in the Google Tag Manager (GTM) node allows users to add a destination to a specific GTM Container and simultaneously remove it from any container it is currently linked to. This operation is useful when managing GTM Destinations across containers, enabling seamless reassignment of destinations without manual unlinking.

Practical scenarios include:

  • Migrating a destination from one container to another.
  • Organizing destinations by linking them to appropriate containers dynamically.
  • Automating GTM container management workflows where destinations need to be re-linked programmatically.

Properties

Name Meaning
Account ID The unique identifier of the GTM Account containing the container.
Container ID The unique identifier of the GTM Container to which the destination will be linked.
Optional Query Parameters Additional optional parameters for the API call. These include:
- Allow User Permission Feature Update (boolean): Allows user permissions feature update if true.
- Built-In Variable Type (options): Various built-in variable types available in GTM.
- Container ID (string): ID of container to merge or related operations.
- Container Version ID (string): Specific container version identifier.
- Copy Settings (boolean): Whether to copy tag settings to new tags.
- Copy Terms Of Service (boolean): Must be true to accept terms of service agreements during copy.
- Copy Users (boolean): Whether to copy users to new tags.
- Destination ID (string): Destination ID linked to a GTM Container (only one of destination_id or tag_id should be set).
- Fingerprint (string): Must match the fingerprint of the account in storage if provided.
- Include Google Tags (boolean): Whether to include accounts associated with Google Tag.
- Page Token (string): Continuation token for paginated results.
- Setting Source (options): Source of config setting after combine (current, other, unspecified).
- Tag ID (string): Tag ID for a GTM Container (only one of destination_id or tag_id should be set).
- Tag Name (string): Name for newly created tag.
- Trigger ID (string): Triggers to be moved to folder.
- Variable ID (string): Variables to be moved to folder.

Output

The output of this operation is a JSON object representing the response from the Google Tag Manager API after linking the destination. It typically includes details about the linked destination resource, such as its identifiers and current state within the container.

No binary data output is involved in this operation.

Dependencies

  • Requires an active Google Tag Manager API OAuth2 credential configured in n8n.
  • The node uses the Google Tag Manager API v2 endpoint 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 the Google Tag Manager API OAuth2 credentials are properly set up and authorized.
  • Required Parameter Missing: Errors indicating missing Account ID or Container ID mean these fields must be filled correctly before execution.
  • Permission Denied: Insufficient permissions on the GTM account or container can cause failures; verify user access rights.
  • Invalid Destination Link ID: Providing an incorrect or non-existent destination link ID will result in API errors.
  • Operation Unknown: If an unsupported operation is selected, the node will throw an error; ensure "Link Destination" is chosen under the Destination resource.

Links and References

Discussion