# Opt Out Helper Functions

To give a customer the option to unsubscribe from receiving marketing messages, you can generate a dynamic link using the opt-out helper function.&#x20;

&#x20;The syntax of this helper function is:

```
{{{optOutLink 'channel'}}}
```

{% hint style="info" %}
Please note the usage of triple braces `{{{...}}}`for the opt-out helper syntax. This is done to ensure that no variables required by a link tag is accidentally escaped.&#x20;
{% endhint %}

#### CrossEngage offers 3 types of opt-out:

1. Opt-out from the current channel a message was dispatched through
2. Opt-out from a particular channel
3. Opt-out from all channels

{% hint style="warning" %}
The links generated by the opt-out helper will only unsubscribe users from CrossEngage messages. This will not update the opt-out status of a user in a particular integration.
{% endhint %}

**Opt-out from messages sent from the current channel**:

To opt-out a user from the current channel a message was dispatched through, use the following syntax within a message template or mapping field value:

```
{{{optOutLink}}}
```

**Opt-out from messages sent from a specific channel**:

To opt out users from channels other than the one the message is dispatched through, use the following syntax within a message template or mapping field value:

```
{{{optOutLink 'Channel'}}}
```

Depending on the channel you would like to produce the link for, you may choose one of the following values:

| Value                  | Description                                                                  |
| ---------------------- | ---------------------------------------------------------------------------- |
| `MAIL`                 | Opt-out from all marketing emails.                                           |
| `DIRECT_MAIL`          | Opt-out from all direct mail campaigns.                                      |
| `BROWSER_NOTIFICATION` | Opt-out from browser notifications.                                          |
| `ONSITE_DISPLAY`       | Opt-out from all onsite display promotions.                                  |
| `EXIT_INTENT`          | Opt-out from all exit intent messages.                                       |
| `PUSH_NOTIFICATION`    | Opt-out from all push notifications across all devices.                      |
| `SEGMENT_TRANSFER`     | Opt-out from all segment transfer campaigns, e.g. Facebook Custom Audiences. |
| `SMS`                  | Opt-out from SMS messages.                                                   |
| `WEBHOOK`              | Opt-out from all webhook campaigns.                                          |

**Opt-out from messages sent from all channels**:

To opt-out users from all channels, you simply need to replace the `Channel` value with `ALL`:

```
{{{optOutLink 'ALL'}}}
```

### Use cases

#### Generating an opt-out link for an email message

For this example, we will prepare the opt-out link for an email message that will be dispatched as part of a future campaign. In the footer section of the email, we will include the opt out link through a hyperlink tag `<a></a>`:

```markup
<footer>
<p>Don't want to receive these emails?</p>
<p>You can unsubscribe <a href="{{{optOutLink}}}">here</a>.</p>
</footer>
```

Once the function is evaluated, it displays a link similar to the following example:

```markup
<footer>
<p>Don't want to receive these emails?</p>
<p>You can unsubscribe 
<a href="https://api.crossengage.io/optout/inbound/webhook/[YourWebtrackingAPIkey]/[XngId]?channelType=MAIL&messageId=[CEMessageId]">here</a>.</p>
</footer> 
```


---

# 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://documentation.crossengage.io/data-and-engagement-platform/messages/personalization/misc.-helper-functions/opt-out-helper-functions.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.
