# Tags

Tags mark contacts: "vip", "ordered_bouquet", "awaiting_delivery". Tags make it easy to branch a scenario and to select mailing recipients. See [Tags and variables](https://support.watbot.org/chatbots/contacts/tags-variables) for details.

Added and removed tags are saved once the code has finished without an error. Inside the code, checks already see the changes.

## getContactTags

```js
getContactTags()
```

Returns all of the contact's tags.

**No parameters.**

**Returns** an array of strings — the tag names. If there are no tags, the array is empty.

```js
var tags = getContactTags();

if (tags.length === 0) {
    sendMessage('Tell us which flowers you like, and we will put together a bouquet.');
}
```

## hasContactTag

```js
hasContactTag(name)
```

Checks whether the contact has a tag.

| Parameter | Type | What to pass |
|---|---|---|
| `name` | String | The tag name. Letter case matters: `VIP` and `vip` are different tags |

**Returns** `true` if the tag is there, and `false` if not.

```js
if (hasContactTag('vip')) {
    setContactVariable('discount', 15);
}
```

## setContactTag

```js
setContactTag(name)
```

Adds a tag to the contact. If the tag is already there, nothing changes.

| Parameter | Type | What to pass |
|---|---|---|
| `name` | String | The tag name |

**Returns nothing.**

```js
setContactTag('ordered_bouquet');
```

## deleteContactTag

```js
deleteContactTag(name)
```

Removes a tag from the contact. If there is no such tag, nothing changes.

| Parameter | Type | What to pass |
|---|---|---|
| `name` | String | The tag name |

**Returns nothing.**

```js
if (hasContactTag('awaiting_delivery')) {
    deleteContactTag('awaiting_delivery');
    setContactTag('order_received');
}
```
