> ## Documentation Index
> Fetch the complete documentation index at: https://help.experro.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Collection Viewed

## Collection Viewed (`collection_viewed`)

**Purpose:**
Track when a user lands on a collection listing page to browse a specific grouping of products.

**When to Fire:**
After your page or API loads the collection data and the associated product SKUs typically on page load or when your view changes to a collection view.

**Payload Schema:**

| Field             | Type             | Description                                                                            |
| ----------------- | ---------------- | -------------------------------------------------------------------------------------- |
| `collection_id`   | string or number | Unique identifier of the collection.                                                   |
| `collection_name` | string           | Human‑readable collection name.                                                        |
| `sku`             | array of strings | Flat array of SKUs for all products in this collection.                                |
| `facets`          | array            | Active filters (e.g. size, brand)—each `{ field, value }`. Use an empty array if none. |
| `request_id`      | string           | Unique identifier for the search request (x-request-id from response headers).         |
| `page_depth`      | string           | Current page number (1, 2, 3, etc.).                                                   |

**Example:**

```js theme={null}
// Assume these variables are populated from your collection response and UI state:
const collectionId      = 'cat123';
const collectionName    = 'Running Shoes';
const selectedFacets    = [];       // e.g. [{ field: 'size', value: '10' }]
const requestId         = collectionResponse.headers.get('x-request-id');
const currentPage       = 1;        // Current page number (1, 2, 3, etc.)
const products          = [
  { sku: 'RS-001', name: 'Lightweight Runner' },
  { sku: 'RS-002', name: 'Marathon Pro' }
];

ExpAnalyticsService.trackCollectionViewed({
  collection_id: collectionId,
  collection_name: collectionName,
  sku: products.map(p => p.sku),
  facets: selectedFacets,
  request_id: requestId,
  page_depth: currentPage
});
```
