# Compliance and consent

> Learn how to notify users when collecting information through Uniform's classification tools.

Source: https://docs.uniform.app/docs/guides/classification/compliance-and-consent

It's important—and a legal requirement in many jurisdictions—to notify people when you want to collect information about them and to get their consent before doing so. For example, it's common that when you visit a website for the first time you are prompted to accept cookies. This gives you the opportunity to give your consent to being tracked.

By default, Uniform won't collect visitor activity data unless you have received consent from the visitor.

The Uniform tracker handles visitor classification, but the
tracker requires the developer to indicate that the visitor
has provided their consent to be tracked. This section
describes how to use this functionality.

> **Tip:**
>
> For more information about the components involved with visitor
> tracking, see the documentation for the [@uniformdev/context](https://sdk.uniform.app/context)
> package.

## Use a cookie to track visitor consent

The following example creates a button that you can add
to an application that the visitor can click in order
to provide their consent.

**React (JS)**

```jsx
import { Context } from '@uniformdev/context';
import React from 'react';
const context = new Context({
  manifest: { project: {} },
  defaultConsent: false, // Disable consent until user grants consent
});
export function CookieConsentPattern() {
  const handleConsentToggleClick = (e) => {
    e.preventDefault();
    const newValue = !context.storage.data.consent;
    context.storage.updateData([{ 
      type: 'consent', 
      data: newValue 
    }]);
    alert(`Storage consent is now ${newValue}`);
  };
  return (
    <div>
      Cookie consent example
      <div>
        <button onClick={handleConsentToggleClick}>Toggle Consent</button>
      </div>
    </div>
  );
}
```

## Disable check for consent

The Uniform Context object handles tracking. When this object
is initialized, you can specify whether consent has been granted.
During development and testing, when an external visitor isn't
involved, it can be convenient to disable the requirement that
the visitor provide their consent.

```jsx
const context = new Context({
  manifest: { project: {} },
  defaultConsent: true,
});
```
