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, enabling users to manage various GTM resources programmatically within n8n workflows. Specifically, for the Template resource and the Create Template operation, it allows creating a new custom template in a specified GTM container workspace.
Use cases include automating the creation of custom templates for tags, triggers, or variables in GTM, which is useful for teams managing multiple containers or environments, or for integrating GTM management into CI/CD pipelines.
Example: Automatically create a new custom template in a GTM workspace when a new marketing campaign starts, ensuring consistent tracking setup without manual intervention.
Properties
| Name | Meaning |
|---|---|
| Account ID | The GTM Account ID where the template will be created. |
| Container ID | The GTM Container ID within the account where the template will be created. |
| Workspace ID | The GTM Workspace ID inside the container where the template will be created. |
| Optional Query Parameters | Additional optional parameters for the API request; can include flags like allowUserPermissionFeatureUpdate, or specify built-in variable types, etc. (various options available). |
| Request Body | JSON object representing the body of the create template request. This should contain the template details as per GTM API requirements. |
Output
The node outputs an array of JSON objects representing the response from the Google Tag Manager API after creating the template. The output JSON structure corresponds to the GTM Template resource, typically including fields such as the template's ID, name, path, fingerprint, and other metadata returned by the API.
No binary data output is involved.
Dependencies
- Requires an active connection to the Google Tag Manager API via OAuth2 credentials.
- The user must configure the node with valid Google Tag Manager API credentials (OAuth2 token).
- Network access to
https://www.googleapis.com/tagmanager/v2is required.
Troubleshooting
- Missing Credentials Error: If the node throws "Missing Google Tag Manager API Credentials," ensure that valid OAuth2 credentials are configured in n8n for Google Tag Manager.
- Required Parameter Errors: The node validates presence of required IDs (Account ID, Container ID, Workspace ID) before making the API call. Missing any of these will cause errors indicating which parameter is missing.
- API Errors: Errors returned from the GTM API are wrapped and presented with the message prefix "Error calling GTM API". Check the error message and stack trace for details. Common issues include invalid IDs, insufficient permissions, or malformed request bodies.
- Request Body Format: Ensure the JSON provided in the Request Body property matches the expected schema for a GTM Template creation request. Invalid JSON or missing required fields will cause API errors.