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, allowing users to manage various GTM resources programmatically within n8n workflows. Specifically, the "List Tags" operation under the "Tag" resource retrieves all tags associated with a specified GTM Container Workspace.

Common scenarios for this node include:

  • Automating the retrieval of GTM tags for auditing or reporting purposes.
  • Integrating GTM tag data into other systems or dashboards.
  • Managing GTM configurations as part of CI/CD pipelines or automated workflows.

For example, a marketing team could use this node to fetch all tags in a container workspace to verify their setup or to export tag configurations for backup.

Properties

Name Meaning
Account ID The unique identifier of the Google Tag Manager Account.
Container ID The unique identifier of the GTM Container within the account.
Workspace ID The unique identifier of the GTM Workspace inside the container.
Optional Query Parameters Additional optional parameters to refine or control the API request. Options include:
- Allow User Permission Feature Update (boolean): Allows user permission feature updates.
- Built-In Variable Type (select from many predefined types).
- Container ID (string): For merging containers.
- Container Version ID (string): Specify published version or others.
- Copy Settings (boolean): Whether to copy tag settings when creating new tags.
- Copy Terms Of Service (boolean): Accept terms of service agreements when copying tags.
- Copy Users (boolean): Whether to copy users from one tag to another.
- Destination ID (string): Linked destination ID for a GTM Container.
- Fingerprint (string): Must match the fingerprint of the account in storage.
- Include Google Tags (boolean): Whether to include accounts associated with Google Tag.
- Page Token (string): Continuation token for paginated results.
- Setting Source (option): Source of config setting after combine (Current, Other, Unspecified).
- Tag ID (string): Tag ID for a GTM Container (mutually exclusive with destination_id).
- 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.

Note: For the "List Tags" operation specifically, the required properties are Account ID, Container ID, and Workspace ID.

Output

The output is a JSON array where each element represents a GTM Tag object retrieved from the specified container workspace. Each tag object contains detailed information about the tag's configuration, such as its ID, name, type, firing triggers, parameters, and other metadata as defined by the GTM API.

No binary data is output by this operation.

Example output structure snippet (simplified):

[
  {
    "tagId": "12345",
    "name": "GA Pageview Tag",
    "type": "ua",
    "parameter": [
      {
        "key": "trackingId",
        "value": "UA-XXXXXX-Y"
      }
    ],
    "firingTriggerId": ["67890"],
    ...
  },
  ...
]

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 list 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 presence of required IDs (Account ID, Container ID, Workspace ID). Missing any of these will cause an error. Double-check input values.
  • API Rate Limits or Permissions: If the API returns errors related to permissions or rate limits, verify that the authenticated user has sufficient access rights and that usage limits are not exceeded.
  • Unknown Operation Error: This indicates an invalid operation parameter; ensure "List Tags" is selected under the "Tag" resource.
  • Pagination Handling: If there are many tags, use the "Page Token" optional parameter to paginate through results.

Links and References

Discussion