# Message variables

> One Premium Link whose pre-filled message changes with each click, filled in with the product, offer or campaign from the link's URL.

Write `{{product}}` in the pre-filled message of a Chat link, share `wa.link/tiendaluna?product=Blue+mug`, and the chat opens with "Blue mug" in its place. One link, one message, and every product, ad or campaign fills in its own words.

## Why use variables

- **One link instead of dozens.** Without variables, every product page or ad needs its own WhatsApp link with its own message. With them, one Premium Link serves them all, and its clicks add up in one place.
- **You know what they want before you reply.** The first message already names the product or the offer the visitor came from.
- **Nothing to update in the app.** A new product only needs a new URL on your side.

## Add a variable

1. Open a Premium Link whose **Link Type** is **Chat**.
2. In **Pre-filled Message**, put the cursor where the value goes. Under the message, **Insert variable** offers `name`, `product`, `code` and `source`, and **Custom…** for a name of your own. You can also type `{{product}}` yourself.
3. A **Message variables** panel appears, with one row per variable. Fill in its **Default value**: the words used when a click brings no value. **Preview** shows the message as it will be sent.
4. Select **Save changes**, or **Create link** on a new link.

> [!TIP]
> Always set a default. Without one, a click that brings no value gets the variable's name instead: "I'd like the product".

## Naming rules

- Two braces on each side: `{{product}}`. Spaces just inside the braces are fine: `{{ product }}`.
- Letters a to z without accents, numbers and underscores: `{{product_name}}`. A name with a hyphen, a space or an accent isn't a variable: it's sent exactly as written, braces included.
- Names are case-sensitive. `{{product}}` is filled by `?product=`, not by `?Product=`.
- A variable can appear more than once in the message. Every copy gets the same value.

## Fill it from the URL

After the address, add `?`, the variable's name, `=` and the value. Join several with `&`: `wa.link/tiendaluna?product=Blue+mug&color=Sand`.

| The click's URL ends in | `{{product}}` becomes          |
| ----------------------- | ------------------------------ |
| `?product=Blue+mug`     | Blue mug                       |
| `?product=`             | The default                    |
| Nothing for `product`   | The default                    |
| Nothing, and no default | `product`, the variable's name |

Write a space as `+` or `%20`. A value that contains `&`, `#` or `+` needs those encoded as `%26`, `%23` and `%2B`. Most website builders and ad tools encode the URL for you.

## Example: your website

Give each product's button the same link with its own value. The message `Hi, I'd like to order the {{product}}.` with the default `piece I saw on your site` covers every page:

```html
<a href="https://wa.link/tiendaluna?product=blue%20mug">Order on WhatsApp</a>
```

A visitor on the blue mug's page sends "Hi, I'd like to order the blue mug." One who finds the link anywhere else sends "Hi, I'd like to order the piece I saw on your site."

## Example: ads and campaigns

Use one link in every ad and change only the value, like `?offer=Summer+sale` in one ad and `?offer=Free+shipping` in another. With `Hi, I saw your {{offer}} ad.` you know which ad started each chat as soon as it opens. The [ads guide](https://walink.com/docs/guides/ads) walks through the setup.

## Good to know

- Variables work on Chat links only: Catalog, Channel and Group links have no message. Smart Links and forms don't fill variables.
- Values still arrive when the link has a [landing page](https://walink.com/docs/premium-links/landing-page) or the [in-app browser](https://walink.com/docs/premium-links/in-app-browsers) bridge turned on.
- Your link's [QR code](https://walink.com/docs/qr-codes) adds `source=qr` to the address so Walink can count scans. That marker never fills a `{{source}}` variable: a scan keeps its default.
- The visitor sees the message before sending and can change it, and anyone can edit a URL. Don't use a variable for anything you need to trust, like a price or a discount code you then honor.
