---
title: Cookie domain
slug: web-experimentation/api/UTrN-cookie-domain
docTags: 
createdAt: 2026-08-05T20:56:13.000Z
---

Instruct Optimizely Web Experimentation to set its cookies on a specific subdomain instead of the default domain. You must call `setCookieDomain` prior to loading the Optimizely snippet. By default, Optimizely sets its cookies on the domain to work across subdomains.

### Syntax

```javascript
window["optimizely"].push(cookieDomain);
```

### Parameters

| Parameter and Type                    | Child Attribute                               | Description                                                                                                   |
| ------------------------------------- | --------------------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| **cookieDomain** *CookieDomainObject* | N/A                                           | An object with the `type` field set to `cookieDomain`. The other fields are the function arguments. Required. |
| **type** *string*                     | Child attribute of type `CookieDomainObject`. | The argument indicating that you are using the `cookieExpiration` function. Required.                         |
| **cookieDomain** *string*             | Child attribute of type `CookieDomainObject`. | The cookie domain.                                                                                            |

### Example Call

```javascript
window["optimizely"].push({
  "type": "cookieDomain",
  "cookieDomain": "www.example.com"
});
```
