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. Specifically, for the "Variable" resource and the "Create Variable" operation, it enables creating a new variable within a specified GTM workspace container.

Use cases include automating the creation of GTM variables as part of deployment pipelines, dynamically managing tag configurations, or integrating GTM variable management into broader workflows without manual intervention.

For example, you might use this node to create a new custom variable in a GTM container workspace whenever a new marketing campaign is launched, ensuring that tracking variables are set up automatically.

Properties

Name Meaning
Account ID The Google Tag Manager Account ID where the variable will be created.
Container ID The GTM Container ID within the account where the variable will be created.
Workspace ID The GTM Workspace ID inside the container where the variable will be created.
Optional Query Parameters Additional optional parameters for the API request.
Request Body JSON object containing the details of the variable to create, such as its name, type, and configuration.

Details on Optional Query Parameters

  • These can include flags like allowUserPermissionFeatureUpdate (boolean), and other specific options depending on the API endpoint.
  • For the "Create Variable" operation, typically no special query parameters are required unless specified by the user.

Request Body

  • This should be a valid JSON object representing the variable's properties according to the GTM API specification.
  • It includes fields such as variable name, type, parameter values, etc.

Output

The output is a JSON array where each element corresponds to the response from the GTM API for the created variable. The structure matches the GTM Variable resource representation, including:

  • accountId: The account ID.
  • containerId: The container ID.
  • workspaceId: The workspace ID.
  • variableId: The unique identifier of the created variable.
  • Other properties describing the variable's configuration and metadata.

No binary data output is involved.

Dependencies

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

Troubleshooting

  • Missing Credentials: If the OAuth2 credentials are not set or invalid, the node will throw an error indicating missing credentials.
  • Required Parameters Missing: The node validates presence of Account ID, Container ID, and Workspace ID. Omitting any will cause an error.
  • Invalid Request Body: Providing malformed JSON or incorrect variable configuration in the request body will result in API errors.
  • API Errors: Any errors returned by the GTM API (e.g., permission denied, quota exceeded) will be surfaced with the message prefixed by "Error calling GTM API".

To resolve:

  • Ensure all required IDs are correctly provided.
  • Validate the JSON structure of the request body against GTM API documentation.
  • Confirm OAuth2 credentials have sufficient scopes and are active.

Links and References


This summary focuses on the "Variable" resource and "Create Variable" operation as requested, based on static analysis of the provided source code and property definitions.

Discussion