# Cookie extractor enrichment
> Extract name-value pairs from first-party cookies and attach them to events as derived contexts.
> Source: https://docs.snowplow.io/docs/pipeline/enrichments/available-enrichments/cookie-extractor-enrichment/
> Documentation index: https://docs.snowplow.io/llms.txt

This enrichment extracts name-value pairs from cookies set on the Collector domain, attaching them to the event as derived entities. It uses the `Cookie` HTTP header.

When using a custom Collector domain, it's possible to capture values in first-party cookies set by other services such as ad servers or content management software (CMS). By capturing these cookie fields and attaching them to the event, you can use the data to better identify users of your website.

This table shows how the cookie and Collector domains interact, indicating whether or not the cookies can be accessed with this enrichment.

| Collector domain    | Cookie domain | Cookies extracted |
| ------------------- | ------------- | ----------------- |
| `c.snowplow.io`     | `acme.com`    | ❌                 |
| `t.acme.com`        | `c.acme.com`  | ❌                 |
| `t.acme.com`        | `acme.com`    | ✅                 |
| `sp.track.acme.com` | `acme.com`    | ✅                 |

## Configuration

The enrichment takes one parameter:

| Parameter | Required | Description                                         |
| --------- | -------- | --------------------------------------------------- |
| `cookies` | ✅        | List of cookie keys for which to extract the value. |

**Console:**

Configure the parameters in the Console enrichment editor. For example:

```json
{
  "cookies": ["sp"]
}
```

**Self-Hosted:**

For Self-Hosted, [provide a complete JSON](/docs/pipeline/enrichments/managing-enrichments/terraform/). For example:

```json
{
  "schema": "iglu:com.snowplowanalytics.snowplow/cookie_extractor_config/jsonschema/1-0-0",
  "data": {
    "name": "cookie_extractor_config",
    "vendor": "com.snowplowanalytics.snowplow",
    "enabled": true,
    "parameters": {
      "cookies": ["sp"]
    }
  }
}
```

***

The example configuration captures the Collector's own `sp` cookie value. In practice, you would probably want to extract other more valuable cookies available on the company domain.

> **Tip: Testing with Micro**
>
> Unsure if your enrichment configuration is correct or works as expected? You can easily test it using [Snowplow Micro](/docs/testing/snowplow-micro/), either [through Console](/docs/testing/snowplow-micro/console/) or [on your machine](/docs/testing/snowplow-micro/local/).
>
> To test first-party cookies, you'll need to run Micro locally and [configure a custom DNS resolution rule](/docs/testing/snowplow-micro/local/remote-usage/#locally-resolving-an-existing-domain-name-to-micro).

## Output

For **each** key listed in the configuration, an `http_cookie` entity is added to the enriched event. Each entity contains only one key/value pair.

### `http_cookie`

**Type:** Entity

Schema for a single HTTP cookie, as defined in RFC 6265

**Properties:**

| Property         | Description |
| ---------------- | ----------- |
| `name` _string_  | _Required._ |
| `value` _string_ | _Required._ |
