# Setting up consent management

{% hint style="info" %}
To enable consent management in the Cookie3 Analytics snippet, ensure your script configuration in the tag includes this line: consent-required="true"
{% endhint %}

## Handling Consent Management with the `window.cookie3` Object

When handling consent management on your website using the `window.cookie3` object, you have access to several methods that allow you to give users control over their tracking and cookie consent decisions. Here's how you can use these methods to implement consent management.

### **Let Users Express Consent**

To let users express their consent for tracking and cookie usage, you can use the following method from `window.cookie3`. Call the `setTrackingConsentGiven()` method when the user agrees to tracking:

```jsx
window.cookie3.setTrackingConsentGiven();
```

### **Check if User Consented to Data Processing**

Before processing any data, it's essential to check if the user has already given their consent. You can check this using the `isTrackingConsentGiven()`method:

```jsx
if (window.cookie3.isTrackingConsentGiven()) {
	// you can handle your custom consent banner logic here
	// for example: hiding not displaying the banner if the consent is given 
}
```

### **Check if User Declined Data Processing**

If the user has explicitly declined tracking or cookie usage, you can detect this by checking the value returned by the `isTrackingConsentGiven()` method.

If the method returns `false`, it means the user has not consented to tracking (or has declined):

```jsx
if (!window.cookie3.isTrackingConsentGiven()) {
  // The user has declined tracking consent
}
```

### **Remember User's Decline Decision Using Local Storage**

When the user declines consent, you can remember their decision by using the `forgetTrackingConsentGiven()` method. This method store the user's decline decision in local storage, ensuring their preference is remembered across sessions:

```jsx
window.cookie3.forgetTrackingConsentGiven();
```

By storing these decisions, the user's choice will be remembered and you won't need to ask for consent again unless the user clears their browser's local storage.

### Summary of Methods:

* **Give consent:**
  * `window.cookie3.setTrackingConsentGiven()`
* **Check consent:**
  * `window.cookie3.isTrackingConsentGiven()`
* **Decline consent:**
  * `window.cookie3.forgetTrackingConsentGiven()`

This consent management flow helps you comply with privacy regulations by giving users full control over how their data is handled, while remembering their preferences for future visits.


---

# 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://docs.cookie3.com/cookie3-analytics/setup-your-site-or-app/setting-up-consent-management.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.
