# Consent
> Documentation for Consent in the web tracker.
> Source: https://docs.snowplow.io/docs/sources/web-trackers/previous-versions/browser-tracker-v3-reference/plugins/consent/
> Documentation index: https://docs.snowplow.io/llms.txt
> Status: Previous version
> Current version: https://docs.snowplow.io/docs/sources/web-trackers/

## Installation

- `npm install @snowplow/browser-plugin-consent`
- `yarn add @snowplow/browser-plugin-consent`
- `pnpm add @snowplow/browser-plugin-consent`

## Initialization

```javascript
import { newTracker, trackPageView } from '@snowplow/browser-tracker';
import { ConsentPlugin } from '@snowplow/browser-plugin-consent';

newTracker('sp1', '{{collector_url}}', {
   appId: 'my-app-id',
   plugins: [ ConsentPlugin() ],
});
```

### Functions

|                         |                                                                                                                                   |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `enableGdprContext`     | [Documentation](/docs/sources/web-trackers/previous-versions/browser-tracker-v3-reference/tracking-events/#gdpr-context)          |
| `trackConsentGranted`   | [Documentation](/docs/sources/web-trackers/previous-versions/browser-tracker-v3-reference/tracking-events/#trackConsentGranted)   |
| `trackConsentWithdrawn` | [Documentation](/docs/sources/web-trackers/previous-versions/browser-tracker-v3-reference/tracking-events/#trackConsentWithdrawn) |

### Context

Adding this plugin will automatically capture the following context:

| Context                                                                                                                                                                                                 | Example                                                                                                                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [iglu:com.snowplowanalytics.snowplow/consent\_document/jsonschema/1-0-0](https://github.com/snowplow/iglu-central/blob/master/schemas/com.snowplowanalytics.snowplow/consent_document/jsonschema/1-0-0) | ![Example consent document context JSON showing id, version, name, and description fields](/assets/images/Screenshot-2021-03-28-at-20.04.43-c5b8a48559a93470a845294b71505551.png) |
