---
title: "Domain Variables - Serpwise Documentation"
description: "Define reusable key-value pairs per domain and reference them in rule actions using template syntax."
url: "https://serpwise.ai/docs/variables/"
source: "https://serpwise.ai/docs/variables/"
---
[Back to Serpwise](/)

Serpwise Documentation

Connect · Configure · Execute

Search documentation

`/`

No documentation found.

↑↓ Navigate Enter to open

Browse documentation

**Domain Variables** are reusable key-value pairs defined per domain. Reference them as `{variable_name}` in rule action values, and the gateway resolves them at request time. Variables keep your rules DRY - update a value once instead of editing every rule that uses it.

* * *

## Managing Variables

Navigate to your domain and open the **Variables** tab to create, edit, and delete variables.

### Creating a Variable

1. Click **Add Variable**
2. Enter a **key** and **value**
3. Save - the gateway cache is automatically invalidated

### Key Naming Rules

- Lowercase letters, numbers, and underscores only
- Maximum 50 characters
- Must be unique per domain
- Cannot be changed after creation (delete and re-create to rename)

### Value Limits

- Maximum 2,000 characters per value
- Values can contain any text, including URLs, HTML snippets, or multi-line content

* * *

## Using Variables in Rules

Reference any variable in a rule action value using curly brace syntax:

```
{my_variable}
```

The gateway replaces `{my_variable}` with the variable’s value at request time. Variables work anywhere template syntax is supported - including `auto_schema` properties, `set_canonical` href, `inject_html` content, and other action parameters.

**Example:** Define a variable `brand_name` with value `Acme Corp`, then use it in a JSON-LD action:

```
{
  "schemaType": "Organization",
  "schema": {
    "name": "{brand_name}",
    "url": "https://{domain}"
  }
}
```

* * *

## System Variables

These built-in variables are always available on every domain. They do not need to be defined in the Variables tab.

| Variable             | Resolves to                             |
|----------------------|-----------------------------------------|
| `{path}`             | URL path (e.g. `/products/blue-widget`) |
| `{domain}`           | Domain name (e.g. `www.example.com`)    |
| `{scheme}`           | Protocol (`https` or `http`)            |
| `{query}`            | Query string (without `?`)              |
| `{full_url}`         | Full request URL                        |
| `{page_title}`       | Current `<title>` text                  |
| `{page_description}` | `<meta name="description">` content     |

* * *

## Priority

If a user-defined variable has the same name as a system variable, the **system variable takes priority**. Avoid naming your variables `path`, `domain`, `scheme`, `query`, `full_url`, `page_title`, or `page_description`.

* * *

## Limitations

- **Maximum value length** - 2,000 characters per variable value
- **Key is immutable** - keys cannot be changed after creation; delete and re-create to rename
- **Gateway cache** - automatically invalidated when variables are created, updated, or deleted
- **No nested references** - variables cannot reference other variables (e.g. `{var_a}` cannot contain `{var_b}`)