> ## Documentation Index
> Fetch the complete documentation index at: https://docs.markifact.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Variable

> Creates a user-defined variable in a Google Tag Manager workspace from a raw Variable resource payload

Creates a user-defined variable in a Google Tag Manager workspace from a raw Variable resource payload. Reference it in tags as \{\{variable name}}; version and publish to take it live.

| | |
| - | - |
| **App** | Google Tag Manager |
| **Operation ID** | `gtm_create_variable` |
| **Type** | Action |
| **Connection** | `gtm` (required) |
| **Credits per run** | 1 |
| **Agent / MCP tool** | Yes |
| **Requires approval** | Yes (write operation) |

## Inputs

| Field | Type | Required | Default | Description |
| - | - | - | - | - |
| `account` | DynamicAccount | Yes | - | Select the Google Tag Manager account. |
| `container` | DynamicAccount | Yes | - | Select the container. |
| `workspace` | DynamicAccount | Yes | - | Select the workspace. |
| `variable_payload` | object or string | Yes | - | Full Variable resource (object or JSON string) matching the Google Tag Manager API v2 Variable spec. Must include name and type (e.g. v for data layer variable, c for constant, jsm for custom JavaScript); settings go in parameter. You can copy a variable from gtm\_list\_variables and edit it (read-only fields are stripped automatically). Example data layer variable: \{"name": "DL - purchase value", "type": "v", "parameter": \[\{"type": "integer", "key": "dataLayerVersion", "value": "2"}, \{"type": "template", "key": "name", "value": "ecommerce.value"}]} |

## Output

**Type**: `Dict`

Returns the created variable as provided by the Tag Manager API, including its variableId.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.