> For the complete documentation index, see [llms.txt](https://docs.hackle.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hackle.io/en/development-guide/sdk/optout.md). Agents can also search and read this documentation through its [MCP server](https://docs.hackle.io/~gitbook/mcp).

# SDK Opt-out

Opt-out is a feature that stops collecting a user's data. It is used to comply with privacy regulations or to respond to a user's request to stop data collection.

{% hint style="info" %}
Even in an opt-out state, SDK features such as A/B Tests, Feature Flags, and In-App Messages continue to work normally.
{% endhint %}

## How to Configure Opt-out

Opt-out can be configured in two ways:

* **Configure at initialization**: Set `optOutTracking` in the SDK initialization config.
* **Configure at runtime**: Change the opt-out state while the app is running using the `setOptOutTracking()` method.

## State Management

{% hint style="warning" %}
The SDK manages the opt-out state only in memory. When the app restarts, it resets to the value set in the initialization config.
{% endhint %}

The opt-out state changed via `setOptOutTracking()` is not persisted when the app restarts. When the app restarts, the `optOutTracking` value set in `HackleConfig` is applied.

### Persistence Management

To persist a user's opt-out setting across app restarts, **you must manage it persistently in your app**.

#### Recommended Implementation Flow

1. When a user changes their opt-out setting, save the state to the app's persistent storage.
2. When the app starts, read the opt-out state from storage and set it in the SDK initialization config.
3. When the state changes while the app is running, update both the storage and the SDK.

#### Persistent Storage Examples by Platform

| Platform           | Persistent Storage                              |
| ------------------ | ----------------------------------------------- |
| iOS                | UserDefaults                                    |
| Android            | SharedPreferences                               |
| JavaScript / React | localStorage                                    |
| React Native       | AsyncStorage or MMKV                            |
| Flutter            | SharedPreferences (shared\_preferences package) |

{% hint style="info" %}
For specific usage of the opt-out API and code examples for persistence management, refer to each SDK's opt-out documentation.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.hackle.io/en/development-guide/sdk/optout.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
