> For the complete documentation index, see [llms.txt](https://documentation.crossengage.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.crossengage.io/data-and-engagement-platform/web-tracking/web-tracking-v1-legacy/tracking-user-behavior/opt-out-from-tracking.md).

# Opt-Out from Tracking

### Overview

To allow users to opt-out from CrossEngage SDK tracking, our library checks if there is an opt-out cookie set in the user's browser. When a cookie is found, the library will not send any tracking requests even when corresponding functions are called, therefore no user actions will be recorded.

{% hint style="warning" %}
If the tracking library does not track user behaviour, it is unable to send any messages through the channels powered by our tracking library:

* Onsite Display
* Browser Notification
* Exit Intent
  {% endhint %}

Please note that:

* By default all users visiting your pages for the first time are opted-in.
* Whenever a user opts-out, this is only valid for the browser they are using at that time. If a user revisits the website through a different browser or device, they will be considered opted-in by the tracking library for that browser / device.
* If a user clears their cookies, the opt-out cookie will be deleted and the user will be opted-in again.
* All cookies have expiration times. Opt-out cookies created through the tracking library have an expiration time of 2 years from the creation time.

## Implementation

#### How to manage opt-out

You can either create and delete the opt-out cookie yourself or use our tracking library support functions.&#x20;

#### Create the cookie manually

To create the opt-out cookie yourself, you have to ensure that you use the exact name, otherwise our library will be unable to find it.

The name of the cookie is:

```
xng.tracking-opt-out
```

#### Create the cookie via support functions

```jsx
xng.setTrackingOptOut([isOptedOut])
```

| Value        | Type    | Description                                                                                                                 |
| ------------ | ------- | --------------------------------------------------------------------------------------------------------------------------- |
| `isOptedOut` | boolean | Provide `true` to opt-out the user from the tracking (creates an opt-out cookie) or `false` to opt-in (deletes the cookie). |

```javascript
xng.optOutTracking()
```

A convenient method to opt-out of tracking for the current browser, the same as using `setTrackingOptOut(true)`.

```javascript
xng.optInTracking()
```

A convenient method to opt-in to tracking for the current browser, the same as using `setTrackingOptOut(false)`.

```javascript
xng.isTrackingOptOut()
```

A method to check opt-out status for the current browser. Returns a boolean value: `true` if the opt-out cookie is present and `false` if not.

## Examples

To opt-out a user, first you need to install XNG library on the page, where you want to initiate the opt-out, then call `xng.optOutTracking()`.

To opt-in a user back, call `xng.optInTracking()`.
