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, allowing users to manage various GTM resources programmatically within n8n workflows. Specifically, the "List Accounts" operation under the "Account" resource retrieves all GTM accounts accessible to the authenticated user.

Common scenarios for this node include:

  • Automating the retrieval of GTM account information for reporting or auditing.
  • Integrating GTM account data into broader marketing or analytics workflows.
  • Synchronizing GTM account details with other systems or databases.

For example, a marketing team could use this node to automatically fetch all their GTM accounts and then trigger further actions like container management or tag updates based on the retrieved accounts.

Properties

Name Meaning
Optional Query Parameters A collection of optional parameters to customize the API request. Options include:
- Allow User Permission Feature Update (boolean): Allows updating user permission features.
- Built-In Variable Type (select from many predefined types).
- Container ID (string): ID of container to merge.
- Container Version ID (string): Specify published version.
- Copy Settings (boolean): Whether to copy tag settings.
- Copy Terms Of Service (boolean): Accept terms of service agreements.
- Copy Users (boolean): Whether to copy users.
- Destination ID (string): Linked destination ID.
- Fingerprint (string): Must match stored fingerprint.
- Include Google Tags (boolean): Include accounts associated with Google Tag.
- Page Token (string): Token for pagination.
- Setting Source (option): Source of config setting after combine.
- Tag ID (string): Tag ID for container.
- Tag Name (string): Name for new tag.
- Trigger ID (string): Triggers to move to folder.
- Variable ID (string): Variables to move to folder.

Note: For the "List Accounts" operation, most of these optional query parameters are not typically required but can be used if supported by the API.

Output

The output is a JSON array where each element represents a GTM account object as returned by the Google Tag Manager API. The structure includes details about each account accessible to the user, such as account ID, name, and other metadata provided by the API.

No binary data is output by this node.

Example output snippet (simplified):

[
  {
    "accountId": "123456",
    "name": "My GTM Account",
    "path": "accounts/123456",
    "shareData": false,
    ...
  },
  {
    "accountId": "789012",
    "name": "Another GTM Account",
    "path": "accounts/789012",
    "shareData": true,
    ...
  }
]

Dependencies

  • Requires an OAuth2 credential configured for Google Tag Manager API access.
  • The node uses the Google Tag Manager API base URL: https://www.googleapis.com/tagmanager/v2.
  • Proper permissions must be granted to the OAuth2 token to list GTM accounts.

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 for each operation. For "List Accounts," no account ID is required, but for other operations, missing IDs will cause errors.
  • API Errors: Errors returned from the Google API (e.g., permission denied, invalid token) will be surfaced with messages prefixed by "Error calling GTM API." Check your API credentials and permissions.
  • Pagination: If there are many accounts, use the "Page Token" optional parameter to paginate through results.

Links and References

Discussion