---
title: "Visitor variables"
description: "Pass page URLs, page titles, URL query parameters, or embed attributes into bot messages, AI context, responses, and AI Actions."
---

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

# Visitor variables

**Visitor Variables** let your website hand context directly to your bot — such as which product page the visitor is viewing, their campaign tag from a URL parameter, or their name and plan tier from your logged-in app — without asking them to type it.

Open **Bot → Settings → Variables** to configure up to **20 variables per bot** (values up to **500 characters** each).

## Four variable sources

Use the **Quick add** presets (`Page URL`, `Page title`, `URL parameter`, `Embed code`) or click **Add variable** to define a variable:

| Source | Where the value comes from | Best for |
| --- | --- | --- |
| **Page URL** (`page_url`) | The URL of the page hosting the widget. Optional **Include query string** checkbox (off by default so sensitive tokens or emails in URLs aren't accidentally stored). | Knowing which product, service, or help page the visitor is on. |
| **Page title** (`page_title`) | The page's HTML `<title>`, read automatically. | Greeting visitors with context (`"Questions about {{page_title}}?"`). |
| **URL parameter** (`query`) | Reads a specific query parameter from the page URL (set **Parameter name**, up to 64 characters, e.g. `ref` or `service`). | Ad campaigns, email links, or partner referrals (`?service=roofing`). |
| **Embed code** (`attribute`) | Reads either a `data-var-<kebab-name>` attribute on the embed `<script>` tag OR `window.ChatVariables` (set in JavaScript before the widget loads). | Logged-in app users (`plan`, `account_name`, `customer_id`). |

### Variable settings

- **Name:** Must start with a letter and use only lowercase letters, numbers, and underscores (`a-z`, `0-9`, `_`, up to 40 characters). Reserved names (`email`, `privacy_consent`, `utm_*`, `gclid`, `fbclid`, `referrer`, `landing_url`) cannot be used. Aminos warns if a variable name collides with a Flow Builder block name.
- **Default value:** Optional fallback (up to 500 characters) used when the source value is missing on a page.
- **Save to responses** *(default on)*: Saves the variable as a column in **Responses**, in the **About this chat** panel of **AI Chat Log**, in CSV/Excel exports, and in lead integrations once the visitor starts interacting.

## Passing embed code variables on your website

At the bottom of **Settings → Variables**, Aminos generates a live **Add it to your website** snippet matching the variables you defined.

### HTML data-var-* attributes

Replace underscores in your variable name with hyphens after `data-var-`:

```html
<script
  async
  src="https://your-platform-domain/w/chat_plugin.js"
  data-bot-id="YOUR_BOT_ID"
  data-var-first-name="Sarah"
  data-var-plan="Pro"
></script>
```
### JavaScript (window.ChatVariables)

Set `window.ChatVariables` before the embed script runs (ideal for web apps and single-page sites):

```html
<script>
  window.ChatVariables = {
    first_name: "Sarah",
    plan: "Pro",
  };
</script>
<script async src="https://your-platform-domain/w/chat_plugin.js" data-bot-id="YOUR_BOT_ID"></script>
```

## Where visitor variables can be used

1. **In bot copy (`{{variable_name}}`):** Works in Welcome messages, CTA messages, Closing messages, and Flow Builder text blocks. Click the copyable `{{name}}` chip next to any variable row to copy it.
2. **In AI conversations:** Aminos automatically supplies active visitor variables to the AI model as untrusted `<visitor_context>` (up to 200 characters per value, 2 KB total) so the AI knows what page or context the visitor is in.
3. **In AI Actions (auto-fill):** If an [AI Action](/ai/ai-actions) has a parameter with the exact same name as an **Embed code**, **Page URL**, or **Page title** variable, Aminos fills it automatically. For security against spoofed links, **URL parameter (`query`)** variables are **never** auto-filled into AI Actions.
4. **In Responses, AI Chat Logs, exports, and integrations:** Any variable with **Save to responses** turned on appears automatically alongside the visitor's answers.

:::tip
Deleted a variable by mistake? Click **Undo** in the 8-second undo bar right after removing a row.
:::

Source: https://docs.aminos.ai/widget/visitor-variables/index.mdx
