Google Tag Manager icon

Google Tag Manager

Use the Google Tag Manager API

Actions102

Overview

The "Update Folder" operation in the Google Tag Manager (GTM) node allows users to update an existing folder within a GTM workspace. This operation is useful for modifying folder properties such as its name or other metadata, helping organize tags, triggers, variables, and other entities inside GTM containers more effectively.

Common scenarios include:

  • Renaming a folder to better reflect its contents.
  • Updating folder metadata to maintain consistency across your GTM workspace.
  • Managing folder structure programmatically as part of automated workflows.

For example, you might use this operation to rename a folder that groups all marketing tags after a campaign ends or to update folder details when reorganizing your GTM container setup.

Properties

Name Meaning
Account ID The GTM Account ID where the folder exists.
Container ID The GTM Container ID containing the folder.
Workspace ID The GTM Workspace ID within the container where the folder resides.
Folder ID The unique identifier of the folder to update.
Optional Query Parameters Additional optional parameters for the request, such as allowUserPermissionFeatureUpdate.
Request Body JSON object containing the updated folder data (e.g., new folder name or other properties).

Notes on Properties

  • All IDs (Account, Container, Workspace, Folder) are required to precisely identify the folder to update.
  • The Request Body should contain the fields you want to update on the folder entity.
  • Optional query parameters can be used to control specific behaviors of the API call.

Output

The output is a JSON array containing the updated folder object returned by the Google Tag Manager API. This object includes the folder's current state after the update, such as its ID, name, path, and any other metadata provided by the API.

Example output structure (simplified):

[
  {
    "folderId": "12345",
    "name": "Updated Folder Name",
    "path": "accounts/ACCOUNT_ID/containers/CONTAINER_ID/workspaces/WORKSPACE_ID/folders/12345",
    "fingerprint": "abcde12345",
    // ... other folder properties ...
  }
]

No binary data is output by this operation.

Dependencies

  • Requires valid Google Tag Manager API credentials with OAuth2 authentication configured in n8n.
  • The node uses the Google Tag Manager API endpoint: https://www.googleapis.com/tagmanager/v2.
  • Proper permissions on the GTM account, container, and workspace are necessary to perform updates.

Troubleshooting

  • Missing Required IDs: Errors will occur if any of the required IDs (Account ID, Container ID, Workspace ID, Folder ID) are not provided. Ensure all these are correctly set.
  • Invalid Request Body: If the JSON in the request body is malformed or missing required fields, the API may reject the update. Validate the JSON structure before sending.
  • Permission Denied: Insufficient permissions on the GTM account or container will cause authorization errors. Verify that the OAuth2 credentials have the necessary scopes.
  • API Errors: The node wraps API errors with messages like Error calling GTM API: <error message>. Check the error message and stack trace for details.
  • Fingerprint Mismatch: If using the fingerprint field in the request body, it must match the current fingerprint of the folder; otherwise, the update will fail due to concurrent modification protection.

Links and References


This summary focuses specifically on the "Folder" resource and the "Update Folder" operation as requested.

Discussion