> ## Documentation Index
> Fetch the complete documentation index at: https://docs.snitcher.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Consent Management

> How to manage user privacy and consent on your customers' websites.

Radar is designed with privacy in mind and includes features to help your customers comply with regulations like GDPR and CCPA. By default, Radar uses session storage. You can configure it to require active consent from your customer's users before using persistent storage (cookies and `localStorage`).

## How It Works

When you enable consent management, Radar operates in two stages on your customer's website:

1. **Before Consent:** The tracker is fully functional but stores all data (like the device ID and user traits) in the end user's `sessionStorage`. This data is cleared when the user closes their tab.
2. **After Consent:** Once the end user gives consent, a specific Radar function must be called. The tracker then migrates all data from `sessionStorage` to `localStorage` and will use persistent storage from that point forward, allowing it to remember users across multiple sessions.

## 1. Enable Consent Management

To enable consent management, set the `waitForConsent` option to `true` in your Radar loader script configuration.

```html HTML theme={null}
<script>
  !function(e){ /* ...loader script... */ }({
    // ... other settings
    "namespace": "YourAppName",
    "waitForConsent": true
  });
</script>
```

When this setting is active, Radar will not use cookies or `localStorage` on your customer's site until you explicitly tell it to via the `giveCookieConsent` method, or automatically via a supported consent management platform (CMP).

## 2. Granting Consent

There are two ways for your customers to grant consent:

### a. Automatic Consent (CMP Integration)

Radar includes built-in integrations with major Consent Management Platforms (CMPs):

* [Cookiebot](https://www.cookiebot.com/)
* [CookieYes](https://www.cookieyes.com/)
* [OneTrust](https://www.onetrust.com/)
* [Transcend](https://transcend.io/)

If your customer uses one of these CMPs, Radar will automatically detect when a user has granted consent and will call giveCookieConsent() behind the scenes. No extra coding is required — simply enable waitForConsent and install Radar after the CMP script.

<Info> This ensures Radar seamlessly respects your customer's existing consent workflow without requiring duplicate consent logic. </Info>

### b. Manual Consent (Custom Banner or Logic)

Your customer will need to implement logic to call the `giveCookieConsent()` method on the tracker's namespace object when one of their users provides consent (for example, by clicking "Accept" on a cookie banner).

```javascript theme={null}
// Your customer calls this when their user accepts the cookie policy
YourAppName.giveCookieConsent();
```

Calling this function does two things:

* It signals to Radar that it now has permission to use persistent storage for that end user.
* It migrates any existing anonymous ID and user traits from that user's session storage to `localStorage`, so their identity is maintained.

<Info>
  The `giveCookieConsent` function only needs to be called once per user. Radar will remember that consent has been granted for all future sessions from that device.
</Info>

#### Example: Integrating with a Cookie Banner

Here is a simple example of how your customer could integrate Radar with a common cookie consent banner on their website. You can provide this snippet to them as a guide.

```html HTML theme={null}
<!-- A cookie banner on your customer's website -->
<div id="cookie-banner">
  <p>We use cookies to improve your experience. Do you accept?</p>
  <button id="accept-cookies">Accept</button>
</div>

<script>
  // The Radar loader script you provide to your customer
  !function(e){ /* ...loader script... */ }({
    "namespace": "YourAppName",
    "waitForConsent": true
  });

  // Logic for the cookie banner
  const banner = document.getElementById('cookie-banner');
  const acceptBtn = document.getElementById('accept-cookies');

  acceptBtn.addEventListener('click', () => {
    // 1. Grant consent in Radar
    window.YourAppName.giveCookieConsent();

    // 2. Hide the cookie banner
    banner.style.display = 'none';

    // 3. (Optional) Store consent preference in a separate cookie
    //    so the banner isn't shown again to this user.
    document.cookie = "cookie_consent=true; path=/; max-age=31536000";
  });
</script>
```
