> For the complete documentation index, see [llms.txt](https://fredhopper.gitbook.io/product-discovery/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fredhopper.gitbook.io/product-discovery/tracking-and-sending-events/activities/view.md).

# View

Track user views and impressions. Understand the distinction between views and impressions, and how to implement view events for navigation, search, and product detail pages using FHR and XO.

**Views** are one of the most basic user **actions**, and are used to track impressions and product views. Views occur whenever a customer navigates to a page, such as through the product listing page, search results, or a product detail page.

* [View on a navigation or search result page ](#views-on-navigation-results)(**FHR** and **XO**)
* [View on a product](#views-on-products-pdps-powered-by-fhr) (**FHR** and **XO**)

## Views vs impressions <a href="#impressions-vs-views" id="impressions-vs-views"></a>

{% hint style="info" %}
The differentiation between views and impressions relates to **tracking for FHR Insights exclusively**.
{% endhint %}

We differentiate between views and impressions:

* **View**: Occurs when a user explicitly navigates to a page; for example, landing on a [PDP ](/product-discovery/tracking-and-sending-events/setup-guide.md#acronyms-and-abbreviations)triggers a view event
* **Impression**: Occurs when a user is passively exposed to a product; for example, a product appears on a [PLP ](/product-discovery/tracking-and-sending-events/acronyms-and-abbreviations.md)during navigation or search

Example:

1. A user searches for a product.
2. The product appears on the PLP. A view event is triggered that is classified as an impression.
3. The user clicks on the product and lands on the PDP. A view is triggered.

This distinction between views and impressions allows for the calculation of the **view conversion rate**, which measures the proportion of impressions that lead to actual views.

## View on navigation or search <a href="#views-on-navigation-results" id="views-on-navigation-results"></a>

Send a view event whenever a user interacts with data retrieved from Fredhopper services as a result of navigation and search. The resulting view action is treated as an [**impression**](#impressions-vs-views).

{% hint style="info" %}
For implementations with [**infinite scroll**](/product-discovery/tracking-and-sending-events/activities/activity-object.md#handling-infinite-scroll), each request for page data should trigger a new event. The **source ID** should come from the response of the triggering request.
{% endhint %}

### Properties

```json
{
    "action":"view",
    "target": {
        "pathToPage": "path/to/page"
    },
    "sourceId":"source-id",
    "metadata": {}
}
```

| Property            | Context                                       | Description                                                                                                                                                                                                                            |
| ------------------- | --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `action`            | All                                           | Must be specified as "view"                                                                                                                                                                                                            |
| `target.pathToPage` | All                                           | The browser path of the page that has been viewed                                                                                                                                                                                      |
| `sourceId`          | All                                           | The [ID that links the FHR or XO response to the event](/product-discovery/tracking-and-sending-events/activities/activity-object.md#source-id), i.e. response ID (`rid` in the FHR response query and `id` in the XO response query)  |
| `metadata.*`        | All                                           | Additional information, such as **context** or **locale**                                                                                                                                                                              |
| `metadata.query`    | The view event is triggered on search results | The search terms that generated the viewed search results; the search term is [available in the FHR response query](/product-discovery/tracking-and-sending-events/activities/activity-object.md#fhr-response-mapping) (`searchterms`) |

{% hint style="danger" %}
The `target.page` field has been deprecated in favor of `target.pathToPage`.

For future insights, ensure you are using the most up to date property names.
{% endhint %}

<details>

<summary>Example: View on navigation results</summary>

```json
{
    "action":"view",
    "target": {
        "pathToPage": "path/to/page"
    },
    "sourceId":"f9caf9db-7549-4498-8c2a-3be977ce48d9",
    "metadata": {
        "locale": "en_GB"
    }
}
```

</details>

<details>

<summary>Examples: View on search results</summary>

<pre class="language-json"><code class="lang-json">{
    "action":"view",
    "target": {
        "pathToPage": "path/to/page"
    },
    "sourceId":"8efbbef2-6640-4c16-b263-1f5a84813a1c",
    "metadata": {
        "query": "trousers",
<strong>        "locale": "en_GB"
</strong>    }
}
</code></pre>

</details>

## View on product <a href="#views-on-products-pdps-powered-by-fhr" id="views-on-products-pdps-powered-by-fhr"></a>

Send a **view** event when a user views a product detail page ([PDP](/product-discovery/tracking-and-sending-events/acronyms-and-abbreviations.md)).

### Properties

```json
{
    "action":"view",
    "target": {
        "product":"product-id"
    },
    "sourceId":"source-id",
    "metadata": {}
}
```

| Property         | Context | Description                                                                                                                                                                                                                           |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `action`         | All     | Must be specified as "view"                                                                                                                                                                                                           |
| `target.product` | All     | The ID of the viewed product, i.e. `secondID`[ in the FHR query response](/product-discovery/tracking-and-sending-events/activities/activity-object.md#fhr-response-mapping)                                                          |
| `sourceId`       | All     | The [ID that links the FHR or XO response to the event](/product-discovery/tracking-and-sending-events/activities/activity-object.md#source-id), i.e. response ID (`rid` in the FHR response query and `id` in the XO response query) |
| `metadata.*`     | All     | Additional information, such as **context** or **locale**                                                                                                                                                                             |

{% hint style="warning" %}
You should **only** include a **source ID** if **the** **page the event is triggered** on is powered by FHR or XO.
{% endhint %}

<details>

<summary>Example: View on product</summary>

```json
{
    "action":"view",
    "target": {
        "product":"83647582"
    },
    "sourceId":"6266c5de-6a3c-4299-af78-3fd17dc3e787",
    "metadata": {
        "locale": "en_GB"
    }
}
```

</details>
