---
title: Context vs Events for Analytics
slug: engine-api/context-events-for-analytics
description: How the Monetate Engine API clients can use context data and events for analytics
image:  https://archbee-image-uploads.s3.amazonaws.com/ceIfEvQHzQk1IVxoRWUh7/K9eTL4jKm7UQINb6zNziJ-20250912-181225.png
docTags: 
createdAt: 2024-05-09T16:53:25.038Z
---

Information sent to Monetate generally falls into two categories:

- **Context** — Session-derived data such as geographic and technographic information or custom variables
- **Events** — Data used for calculating analytics and key performance indicators (KPIs)

Context is determined per session and can safely be sent multiple times—by both the Monetate tag and Engine API, for example—with no effect on analytics.

:::hint{type="info"}
Ensure that you include the end user’s `userAgent` string so that sessions are registered properly as stealth or not. If the value of `userAgent` lacks specific browser or OS details, then it's identified as automated and put into Stealth Mode.
:::

However, events can potentially be recorded by both the Monetate tag and Engine API in [hybrid implementations](docId\:ZFxS45Ymf6aIcWwKKgXcC). Be aware of the following factors:

- API events are recorded at the session level for experience analytics, but you can view the aggregate count (how many times the event occurred) in raw data.
- Product views are recorded individually but are only used for processing [recommendation algorithms](https://docs.monetate.com/docs/recommendation-algorithms). What matters is if a product was viewed in a session, not how many times it was viewed.
  - The [Most Viewed (Product Detail Page)](https://docs.monetate.com/docs/recommendation-algorithms#most-viewed-product-detail-page-) recommendation algorithm can be influenced by multiple views in a given session.
  - [Collaborative recommendation algorithms](https://docs.monetate.com/docs/recommendation-algorithms#collaborative-standard-algorithms), such as Viewed and Also Viewed and Purchased and Also Purchased, aren't effected by multiple views in a given session and solely function based on whether a product was viewed in a session.
- Cart events are recorded as an event, and Monetate considers the most recent event for behavioral purposes. For this reason, even for traditional Monetate tag–based implementations, properly recording all applicable cart items on every track is important.
- Purchases are recorded individually but are deduplicated by the `purchaseId` value. If a Monetate tag–based integration and Engine API integration report the same `purchaseId` value, then only one is recorded.

:::hint{type="info"}
Page views aren't currently supported by the Engine API. As a result, average page views and bounce rate metrics cannot be calculated for Omnichannel experiences.
:::

## Custom Events

You can send any event, such as clicks and impressions, that falls outside of Monetate's built-in events by using [monetate\:record\:PageEvents](docId\:x7k8z81A-G9boBqmny0hB).

:::CodeblockTabs
Example Request with monetate\:record\:PageEvents

```json
{
  "eventType": "monetate:record:PageEvents",
  "pageEvents": 
  [
    "myEvent"
  ]
}
```
:::

The list of events sent can be any event configured in Monetate by following the steps in [Creating a Custom Engine API Event](./#creating-a-custom-engine-api-event). These events are identified in the API by their Unique Key, an alphanumeric string set when you create the event.

:::hint{type="warning"}
You can't use `monetate:record:PageEvents` to send an event that doesn't have a Unique Key.
:::

You can configure any event to have a Unique Key. Requests referencing this key from the time the key is set result in that event being sent to Monetate. When one or more of these events are sent via the Engine API, they're recorded within Monetate as having occurred for the customer at the time sent. For example, in the example `monetate:record:PageEvents` request, an event with the Unique Key `myEvent` is sent. This value was set using the **Unique Key** field in the Create Engine API Event modal in the Monetate platform.

A number of rules govern how Unique Keys function:

- Each key must be unique and can only be used if it actively references the event in question.
- You can't set a key retroactively but you can change it. If you send a Unique Key in a `monetate:record:PageEvents` request *before* you create the key, then the Unique Key is ignored.
- The Engine API also ignores any Unique Key value in a request that no longer references an event, such as when an Unique Key is changed.

Custom events are useful for reporting and for use as goal metrics in Monetate experiences.

## Creating a Custom Engine API Event

Follow these steps to create a custom Engine API event in the Monetate platform.

1. Log into the [Monetate platform](https://marketer.monetate.net/auth/login/).
2. Click **COMPONENTS** in the top navigation bar and then select **Events**.

   ![Callout of the Events option in the COMPONENTS menu of the Monetate platform](https://dyzz9obi78pm5.cloudfront.net/app/image/id/6453ef3af6a6be167836a733/n/components-components-to-events.png)
3. Click the arrow to the right of **CREATE EVENT** and then select **Create Engine API Event**.

   ![Callout of the 'Create Engine API Event' option in the 'CREATE EVENT' selector](https://dyzz9obi78pm5.cloudfront.net/app/image/id/6453f1c5e5dfd8198618d8b2/n/events-list-page-create-event-create-engine-api-event.png)
4. In the Create Engine API Event modal, give the event a title and description, then enter into **Unique Key** the value to be sent when this event occurs. Leave **API** as the selected option for **Category**. Optionally, enter a subcategory and any [action conditions](https://docs.monetate.com/docs/action-conditions).

   ::Image[]{src="https://dyzz9obi78pm5.cloudfront.net/app/image/id/6453f31a68f32229523e85a3/n/events-list-page-create-event-create-engine-api-event-modal.png" size="66" width="651" height="565" position="center" alt="The Create Engine API Event modal" showCaption="false"}
5. Click **SAVE**.

:::hint{type="info"}
Monetate recommends creating one or more action conditions to limit the event to pages on which it should be tracked.
:::

When a customer meets the criteria of the event, send a request with `monetate:record:PageEvents` that contains the Unique Key that you input for the custom event.

You also must add the custom API event to the WHY settings of an Omnichannel experience as a secondary metric. Follow steps 5 and 6 in [Add Custom Metrics to an Experience](https://docs.monetate.com/docs/add-custom-metrics-to-an-experience#custom-metric) to add and select the event in the Monetate platform's Experience Editor.
