# Variables

### Variable Types and Prefixes

| Prefix | Type                | Description                     |
| ------ | ------------------- | ------------------------------- |
| dlv    | Data Layer Variable | Reads value from dataLayer      |
| cookie | 1st Party Cookie    | Reads value from cookie         |
| js     | JavaScript Variable | Reads JS global variable        |
| cjs    | Custom JavaScript   | Computes value with JS function |
| url    | URL Variable        | Reads value from URL            |
| aev    | Auto-Event Variable | Reads clicked element attribute |
| const  | Constant            | Fixed value                     |

***

### Most used: DLV

A Data Layer Variable (DLV) reads values pushed via dataLayer.push().

```typescript
// When this code runs in your project:
window.dataLayer?.push({
  event: 'create_project',
  project_id: '123',       // ← DLV reads this value
  source_page: 'dashboard',
})
```

```
In GTM:
DLV - project_id   → captures "123"
DLV - source_page  → captures "dashboard"
```

***

### How to add a variable

1. Select a variable type from the left library panel
2. Drag it onto the canvas
3. Configure in the right settings panel:

| Field      | Description        | Example           |
| ---------- | ------------------ | ----------------- |
| Name       | Variable name      | dlv - project\_id |
| Source Key | dataLayer key name | project\_id       |

\[📸 IMAGE: Variable settings panel screenshot]

***

### Naming Convention

```
[prefix] - [value description]

Examples:
dlv - project_id
dlv - source_page
dlv - user_type
cookie - session_id
const - ga4_measurement_id
```

> 💡 When typing a variable name, a list of commonly used names appears as autocomplete suggestions.

***

### Connect variable to tag parameter

Variables are used as parameter values in tags.

```
Tag parameter:
Key:   project_id
Value: {{dlv - project_id}}  ← references the variable
```

In Taviqo, connecting a variable node to a tag node automatically maps it to the tag's parameters.

\[📸 IMAGE: Canvas showing variable node connected to tag node]

***

### Recommended Parameters

| Key             | Description               |
| --------------- | ------------------------- |
| project\_id     | Project unique ID         |
| workspace\_id   | Workspace unique ID       |
| source\_page    | Page where event occurred |
| source\_section | Section within the page   |
| button\_name    | Name of clicked button    |
| plan\_name      | Plan name                 |
| user\_type      | User type                 |
| login\_status   | Login status              |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://taviqo.gitbook.io/taviqo-docs/features/variables.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
