---
title: Collect only with consent
description: Gate Amplitude SDK initialization behind consent so no Amplitude cookies or events exist until a user opts in.
product: data
lang: en
last_updated: 2026-11-20
token_estimate: 747
---
# Collect only with consent

This is one of three consent methods described in the [privacy and consent overview](https://amplitude.com/docs/data/privacy-and-consent-implementation). Choose it when your policy requires consent before analytics begins. It's the clearest option, and the easiest model to explain to users and auditors, because nothing starts until the user grants consent.

> For AI agents: a documentation index is available at [/docs/llms.txt](/docs/llms.txt). Append `.md` to any page URL for markdown, or send `Accept: text/markdown`.

Before you implement this method, align with your legal and privacy teams on what's allowed in your case. This page shows you how to implement a decision your team has already made; it doesn't replace legal advice.

## How it works

In Browser SDK 2, the SDK may create Amplitude cookies as soon as it initializes. To avoid cookies before consent, don't initialize the SDK until the user has consented.

## Set it up in Amplitude

Only call `amplitude.init()` after you capture consent. Let your site load normally, and hold off on initializing until your consent tool confirms that analytics is allowed.

```javascript
import * as amplitude from '@amplitude/analytics-browser';

// User hasn't consented yet.
// Don't initialize the SDK here.

function onConsentGranted() {
  amplitude.init('AMPLITUDE_API_KEY');
}
```

To anonymize a user after logout, call `amplitude.reset()`. This clears the `userId` and creates a new `deviceId`. The next activity appears as a new anonymous user until the user signs in again.

## Centralize SDK initialization

Make `amplitude.init(...)` run from one place only. If several teams initialize the SDK in different parts of the site, proving that consent gates tracking becomes much harder.

## What to do outside Amplitude

Use your consent management platform (CMP) to control whether initialization happens. Amplitude doesn't provide a default CMP integration, so your CMP needs to pass the consent outcome into your Amplitude implementation.

> **Note:** How to classify Amplitude cookies in your CMP
>
> Most organizations classify Amplitude's analytics cookies as analytics or performance cookies, not marketing cookies. If your consent banner separates cookie categories, configure Amplitude under the analytics or performance category in your consent management platform.
>
> In limited circumstances, such as when you use Amplitude only for feature flagging or for Session Replay in a security or debugging context, the relevant cookies may qualify as "necessary." Your legal team should confirm the correct classification for your specific use case.

## Verify the setup

Open your browser developer tools and confirm that no Amplitude cookies are present before consent. For the full pre-launch test matrix, refer to [Validate your setup before launch](https://amplitude.com/docs/data/privacy-and-consent-implementation/implement-privacy-controls#validate-your-setup-before-launch).

