Actions84
- Account Actions
- Built-In Variable Actions
- Client Actions
- Container Actions
- Destination Actions
- Environment Actions
- Folder Actions
- Google Tag Configuration Actions
- Tag Actions
- Template Actions
- Transformation Actions
- Trigger Actions
- User Permission Actions
- Variable Actions
- Version Actions
Overview
This node integrates with the Google Tag Manager (GTM) API, allowing users to manage various GTM resources programmatically within n8n workflows. Specifically, for the "Variable" resource and the "Create Variable" operation, it enables creating a new variable inside a specified GTM workspace container.
Use cases include automating the creation of GTM variables as part of deployment pipelines, dynamically managing tags and triggers based on external data, or integrating GTM configuration changes into broader marketing or analytics automation workflows.
For example, you might use this node to create a new custom variable in GTM whenever a new campaign is launched, ensuring that tracking parameters are automatically set up without manual intervention.
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. These include: |
| - Allow User Permission Feature Update (boolean): Allows user permission feature updates. | |
| - Built-In Variable Type (options): Select from many predefined built-in variable types. | |
| - Other parameters related to container versions, copying settings, fingerprints, etc. | |
| Request Body | JSON object representing the body of the request, containing the details of the variable to create. |
The Request Body should contain the full definition of the variable according to the GTM API specification, including its name, type, parameter values, and other relevant properties.
Output
The node outputs an array of JSON objects representing the response from the Google Tag Manager API after creating the variable. This typically includes the newly created variable's metadata such as its ID, name, type, parameter values, fingerprint, path, and other attributes defined by the GTM API.
No binary data output is produced by this operation.
Dependencies
- Requires a valid Google Tag Manager API OAuth2 credential configured in n8n.
- The node uses the Google Tag Manager v2 REST API endpoint (
https://www.googleapis.com/tagmanager/v2). - Proper permissions on the GTM account, container, and workspace are necessary to create variables.
Troubleshooting
- Missing Credentials Error: If the node throws an error about missing credentials, ensure that a valid Google Tag Manager OAuth2 credential is configured and selected.
- Required Parameter Errors: The node validates required parameters like Account ID, Container ID, Workspace ID, and the request body. Missing any of these will cause errors. Double-check that all required IDs and the request body JSON are provided.
- API Errors: Errors returned from the GTM API (e.g., permission denied, invalid request body) will be surfaced with messages prefixed by "Error calling GTM API". Review the message and stack trace for details.
- Invalid JSON in Request Body: Ensure the JSON entered in the Request Body field is well-formed and matches the expected structure for a GTM variable.
Links and References
This summary focuses on the "Variable" resource and "Create Variable" operation as requested, describing the input properties, output, dependencies, and common troubleshooting points based on static analysis of the node's source code and provided property definitions.