Actions102
- 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
- Workspace Actions
- Zone 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 Template resource and the Create Template operation, it enables creating a new custom template in a specified GTM container workspace.
Use cases include automating the deployment of custom templates across multiple GTM containers or workspaces, integrating template creation into CI/CD pipelines, or dynamically generating templates based on external data or events.
Example: Automatically create a new GTM custom template when a new marketing campaign is launched, 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 belongs. |
| 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; includes various flags and filters. |
| Request Body | JSON object representing the details of the template to create, including its configuration. |
Details on Optional Query Parameters (subset relevant to Template Create):
- Various boolean flags and string options that can modify the behavior of the API call.
- Examples include
allowUserPermissionFeatureUpdate,copySettings,copyUsers, etc., but these are generic and may not all apply directly to template creation.
Output
The node outputs an array of JSON objects corresponding to the responses from the GTM API for each input item processed.
For the Create Template operation, the output JSON contains the newly created GTM Template resource as returned by the Google Tag Manager API. This typically includes fields such as the template's unique ID, name, path, fingerprint, and other metadata describing the custom template.
No binary data output is produced by this operation.
Dependencies
- Requires valid Google Tag Manager API credentials configured in n8n using OAuth2 authentication.
- The node uses the official GTM API endpoint at
https://www.googleapis.com/tagmanager/v2. - Proper permissions on the GTM account and container are necessary to create templates.
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 like Account ID, Container ID, Workspace ID, and Template details. Missing any of these will cause errors. Double-check that all required IDs and the request body 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 provided in the Request Body property is well-formed and matches the expected schema for a GTM Template.
Links and References
- Google Tag Manager API Documentation - Templates
- Google Tag Manager API Overview
- n8n OAuth2 Credential Setup
This summary focuses on the Template resource's Create Template operation as requested, based on static analysis of the provided source code and properties.