# UserActivity & UserEvent

User activity management is at the core of audience management services.&#x20;

**A UserActivity is a collection of events (UserEvent) done by a single user in a given period of time**. For instance, mediarithmics considers that [a website activity is a session of no more than 30mn on a given website](https://developer.mediarithmics.io/data-streams/data-ingestion/real-time-user-tracking#session-aggregation). An UserActivity is also linked to its referrer (like Google, Yahoo!, ...), if an user switch of referrer an go back to the same website, it will be considered like a new activity. Events can be given any name and any properties, but some predefined names and properties can be used to trigger specific treatment on the data.

**You send UserEvent** to mediarithmics, that are **aggregated and encapsulated into UserActivity**. Some UserActivity only have one UserEvent, but some can have multiple UserEvent.&#x20;

{% hint style="info" %}
To visualize user activities for a specific user, go to the navigator > Audience > Monitoring and select a user id.&#x20;

You can then view the complete JSON for each activity.
{% endhint %}

User activities and events can be indexed and queried using APIs and/or the query engine, if their properties fit the object tree schema.

When an activity is ingested via [the real time tracking pipeline](https://developer.mediarithmics.io/data-streams/data-ingestion/real-time-user-tracking), it will trigger some dedicated processes like [event rules](https://developer.mediarithmics.io/data-streams/data-ingestion/real-time-user-tracking/event-rules), [activity analyzers](https://developer.mediarithmics.io/data-streams/data-ingestion/real-time-user-tracking/activity-analyzers), ...&#x20;

## User Activity object

A minimal user activity is an object with the following properties.

| field                                                                                 | type                                        | description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------------------------------------------------------------- | ------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| $ts                                                                                   | Long                                        | The timestamp of the activity. For a session, it should correspond to the start date (Unix Epoch Time in **milliseconds**)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| $type                                                                                 | String enum                                 | <p>The activity type : <br>- <code>SITE\_VISIT</code>for activities happening on a channel of type site<br>- <code>APP\_VISIT</code>for activities happening on a channel of type app</p><p>-<code>CTV\_VISIT</code> for activities happening on a channel of type CTV<br>- <code>DISPLAY\_AD</code> for activities involving ad view and ad click events. See <a href="../data-streams/data-ingestion/real-time-user-tracking/ads-exposure">Ads exposure tracking</a> for more information.<br>- <code>EMAIL</code> when users read a mail or click in a link inside it. For more information, see <a href="../data-streams/data-ingestion/real-time-user-tracking/email-views-and-clicks">Email views and clicks</a>.<br>- <code>TOUCH</code> for other activities</p><p></p><p>There are also activity types specific to <a href="../advanced-usages/automations">automations</a>:</p><p>- <code>USER\_SCENARIO\_START</code> when a scenario starts</p><p>- <code>USER\_SCENARIO\_STOP</code> when a scenario stops</p><p>- <code>USER\_SCENARIO\_NODE\_ENTER</code> when a new scenario node is entered</p><p>- <code>USER\_SCENARIO\_NODE\_EXIT</code> when a scenario node is exited</p> |
| $session\_status                                                                      | String enum                                 | The sessions status, automatically updated by mediarithmics. `NO_SESSION`, `IN_SESSION`, `CLOSED_SESSION`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| $ttl                                                                                  | Integer                                     | The Time To Live in minutes for the storage of this activity. `0` means no expiration                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| $user\_agent\_info                                                                    | [User Agent info](#user-agent-info) object  | Optional. Information of the device                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| $user\_agent\_id                                                                      | String                                      | <p>The identifier of the user device as provided by the user id mapping service. ex: <code>vec:89090939434</code><br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Legacy, please use <code>$user\_identifiers</code> instead</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| <p>$user\_account\_id</p><p>(in addition to <code>$compartment\_id</code>)</p>        | String                                      | <p>The user account id of the user<br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Legacy, please use <code>$user\_identifiers</code> instead</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| <p>$compartment\_id</p><p>(in addition to </p><p><code>$user\_account\_id</code>)</p> | Integer                                     | <p>The ID of the compartment associated with this activity<br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Legacy, please use <code>$user\_identifiers</code> instead</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| $email\_hash                                                                          | Email Hash Object                           | <p>The email hash object { “$hash”:…, “$email”:…} <br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Legacy, please use <code>$user\_identifiers</code> instead</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| $user\_identifiers                                                                    | List of [User Identifier](#user-identifier) | <p>A list of all identifiers relative to the activity.<br>You can have many of each type.<br><span data-gb-custom-inline data-tag="emoji" data-code="26a0">⚠️</span> Use this list rather than the legacy properties ($user\_agent\_id, $user\_account\_id & $compartment\_id, $email\_hash)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| $origin                                                                               | [Activity Origin](#activity-origin)         | The activity origin                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| $location                                                                             | [Activity Location](#activity-location)     | The activity location                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| $events                                                                               | List of [User Event](#user-events-object)   | A list of user events attached to this activity                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| $unique\_key                                                                          | String                                      | The unique\_key of the activity formatted as an uuid-v1. If empty, the platform generates one automatically                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| \[any custom property]                                                                | Any                                         | The value of a custom property                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |

{% hint style="info" %}
User activities could be enriched with any custom property, and specific activity types can have additional base properties.

**Base properties names all begin with '$'**. That's a good way to differentiate base properties and your custom properties if you don't start your property names with that same character.
{% endhint %}

{% hint style="warning" %}
**A few things to keep in mind :**&#x20;

* **Always prefer predefined properties** to custom properties when they exist, as the platform automates a lot of actions based on those properties. You could miss some critical steps in having well organized data
* **Activities are limited** to 8000 characters.
* For user identification you can :
  * **either use** $user\_identifiers;
  * **or use** $user\_agent\_id, $user\_account\_id, $compartment\_id, and $email\_hash
    {% endhint %}

### Site visits user activities

Their type is SITE\_VISIT. They have those additional base properties :

| field              | type    | description                      |
| ------------------ | ------- | -------------------------------- |
| $site\_id          | String  | The site ID (channel)            |
| $session\_duration | Integer | The session duration in seconds. |

### App visits user activities

Their type is APP\_VISIT. They have those additional base properties :

| field              | type               | description                      |
| ------------------ | ------------------ | -------------------------------- |
| $app\_id           | String             | The mobile app ID (channel)      |
| $session\_duration | Integer (Optional) | The session duration in seconds. |

### CTV visits user activities

Their type is Ct\_VISIT. They have those additional base properties :

| field              | type               | description                      |
| ------------------ | ------------------ | -------------------------------- |
| $ctv\_id           | String             | The CTV ID (channel)             |
| $session\_duration | Integer (Optional) | The session duration in seconds. |

### Channels

If you have multiple sites/apps (Mobile or CTV) you can create a channel for each one of them. Each channel will have an ID, representing either a site ID or an app ID.

When you attach site IDs or app IDs to your user activities, you link them to the corresponding channel.

This is useful for[ attaching data privacy rules](https://developer.mediarithmics.io/advanced-usages/data-privacy-compliance/user-choices) to a site or an app, or when you'll want to create queries and segments, allowing you to select only users having activities on a specific site or app.

### User Identifier

A user identifier is either a user account, a user email, or a user agent.

#### User Account

| field              | type                 | description                                             |
| ------------------ | -------------------- | ------------------------------------------------------- |
| $type              | Constant String      | USER\_ACCOUNT                                           |
| $compartment\_id   | Integer              | The ID of the compartment associated with this activity |
| $user\_account\_id | String               | The user account id of the user                         |
| $expiration\_ts    | Timestamp (Optional) | The account's expiration timestamp                      |

#### User Email

| field           | type                 | description                      |
| --------------- | -------------------- | -------------------------------- |
| $type           | Constant String      | USER\_EMAIL                      |
| $hash           | String               | The email hash                   |
| $email          | String (Optional)    | The "raw" email                  |
| $expiration\_ts | Timestamp (Optional) | The email's expiration timestamp |

#### User Agent

| field                        | type                 | description                                                                                                                                   |
| ---------------------------- | -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| $type                        | Constant String      | USER\_AGENT                                                                                                                                   |
| $user\_agen&#x74;*\_*&#x69;d | String               | <p>The user agent id<br>Currently support agent type : <br>- vector id : <code>vec:vector\_id</code> ; e.g.: <code>vec:89090939434</code></p> |
| $expiration\_ts              | Timestamp (Optional) | The agent's expiration timestamp                                                                                                              |

#### User Agent info

| Property          | Type      | Description                                                                                                                                                                                                                                                                                 |
| ----------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| $initial\_ts      | Timestamp | Timestamp at which device has been seen                                                                                                                                                                                                                                                     |
| $form\_factor     | Enum      | Indicates the format of the device. Possible values: `PERSONAL_COMPUTER`, `SMART_TV`, `GAME_CONSOLE`, `SMARTPHONE`, `TABLET`, `WEARABLE_COMPUTER`, `OTHER`.                                                                                                                                 |
| $os\_family       | Enum      | The operating system family of the device. Possible values: `WINDOWS`, `MAC_OS`, `LINUX`, `ANDROID`, `IOS`, `TIZEN`, `WEB_OS`, `ANDROID_TV`, `GOOGLE_TV`, `TV_OS`, `FIRE_TV`, `ROKU_TV`, `TITAN_OS`, `OTHER`.                                                                               |
| $browser\_family  | Enum      | <p>If the device is a browser.</p><p>Possible values: <code>OTHER</code>, <code>CHROME</code>, <code>IE</code>, <code>FIREFOX</code>, <code>SAFARI</code>, <code>OPERA</code>, <code>STOCK\_ANDROID</code>, <code>BOT</code>, <code>EMAIL\_CLIENT</code>, <code>MICROSOFT\_EDGE.</code></p> |
| $browser\_version | String    | The version of the browser.                                                                                                                                                                                                                                                                 |
| $brand            | String    | The brand of the device (ex.: "Apple")                                                                                                                                                                                                                                                      |
| $model            | String    | The model of the device (ex.: "Iphone 14")                                                                                                                                                                                                                                                  |
| $os\_version      | String    | The version of the operating system (ex.: "macOS 10.15 Catalina")                                                                                                                                                                                                                           |
| $carrier          | String    | The service provider that ensures connectivity of the device (ex: "AT\&T")                                                                                                                                                                                                                  |
| $raw\_value       | String    | Raw user agent value                                                                                                                                                                                                                                                                        |
| $agent\_type      | Enum      | Indicates the type of device. Possible values: `WEB_BROWSER` `MOBILE_APP` or `CTV_APP`                                                                                                                                                                                                      |

### Activity Location

| field        | type                   | description                                                                                     |
| ------------ | ---------------------- | ----------------------------------------------------------------------------------------------- |
| $source      | String (Optional)      | The location source (`IP`, `GPS`, `OTHER`)                                                      |
| $country     | String (Optional)      | The country’s name                                                                              |
| $region      | String (Optional)      | The region’s name                                                                               |
| $iso\_region | String (Optional)      | The region iso (ISO 3166-2)                                                                     |
| $city        | String (Optional)      | The city’s name                                                                                 |
| $iso\_city   | String (Optional)      | The city iso (UN/LOCODE)                                                                        |
| $zip\_code   | String (Optional)      | The zip code                                                                                    |
| $latlon      | Array\[Double, Double] | The latitude and longitude where the first element is the latitude and the second the longitude |

### Activity Origin

In the mediarithmics vocabulary, the activity origin refers to **the last digital channel leading to user interaction**. It is key information to be used to analyze the results and the performance of marketing activities.&#x20;

This interaction can be a Touch (the user views a banner or an email) or a Visit (the user visits a web site or an app). In both cases, the $origin object of the [user activity](#user-activity-object) is used to capture the information related to the originating channel.

The $origin object is a customizable object with predefined properties as follows:

| origin field                    | description                                                        |
| ------------------------------- | ------------------------------------------------------------------ |
| $ts                             |                                                                    |
| $channel                        | the communication channel. ex: cpc, newsletter, banner, video, ... |
| $source                         | the source of the traffic. ex: google.com, news-foo.com, ...       |
| $campaign\_name                 | the campaign name                                                  |
| $campaign\_technical\_name      | the campaign technical name                                        |
| $campaign\_id                   | the campaign id                                                    |
| $sub\_campaign\_technical\_name | the sub campaign (Ad Group)  technical name                        |
| $sub\_campaign\_id              | the sub campaign (Ad Group) id                                     |
| $message\_id                    |                                                                    |
| $message\_technical\_name       |                                                                    |
| $keywords                       | the keywords used in the search ex:sport+shoes                     |
| $creative\_name                 | the creative name                                                  |
| $creative\_technical\_name      | the creative technical name                                        |
| $creative\_id                   | the creative id                                                    |
| $engagement\_content\_id        |                                                                    |
| $social\_network                | the social network                                                 |
| $referral\_path                 | the URL of the referral                                            |
| $log\_id                        | the custom unique identifier for the activity origin               |
| $gclid                          | the unique identifier for a Google AdWords click                   |

#### Origin calculation

The origin of user activity is calculated in different ways depending on the activity type (Touch/Visit) and source (Tag/API):

* **for a visit on a site or an app**:  from the analysis of the referrer and/or the query parameters provided in the destination URL (like the UTM parameters used by Google Analytics)
* **for touch events generated by campaigns** delivered by the mediarithmics platform, the origin is automatically calculated from campaign information
* **for touch events** (pixel events in emails or banners) the origin is calculated from the properties provided in the event (predefined properties)
* **for an activity inserted through the API,** the origin fields can be directly filled with the relevant data.

{% hint style="info" %}
A user activity can only have one origin. If a user comes back from a different origin in a live session. The current session is closed and a new session is opened with the second origin.
{% endhint %}

#### Origin detection based on Google Analytics parameters (UTM)

Here is the table of correspondence between mediarithmics origin fields and Google Analytics parameters:

| origin field    | url parameters | example / description                                        |
| --------------- | -------------- | ------------------------------------------------------------ |
| $channel        | utm\_medium    | <p>utm\_medium = email or<br>$channel = email</p>            |
| $source         | utm\_source    | utm\_source = base loyalty program                           |
| $campaign\_name | utm\_campaign  | utm\_campaign = back to school                               |
| $creative\_name | utm\_content   | utm\_content = template 1                                    |
| $keywords       | utm\_term      | <p>utm\_term = sport+shoes or<br>$keywords = sport+shoes</p> |
| $gclid          | gclid          | Google Click Identifier                                      |

#### Origin detection based on AT Internet parameter (xtor)

Here is the table of correspondence between mediarithmics origin fields and AT Internet parameter:The structure of the xtor parameter is as follows:

```
xtor=A-B-C-D-E-F-G-H
```

The xtor parameter is automatically analyzed to fill the following origin fields:

| origin field    | xtor field | example / description                                                                                                                                                                                     |
| --------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| $source         | A          | EPR when xtor=EPR-14234                                                                                                                                                                                   |
| $campaign\_name | B          | 7880 when xtor=AD-7880                                                                                                                                                                                    |
| $creative\_name | C          | [ad\_version7](https://developer.mediarithmics.com/guides/user-activities/activity-origin/) when xtor=AD-3030-[ad\_version7](https://developer.mediarithmics.com/guides/user-activities/activity-origin/) |

#### Marketing Channel inference

According to [AT Internet documentation about xtor parameter](https://help.atinternet-solutions.com/en/configurations/configcampaigns_en.htm#MiniTOCBookMark5), source may be related to marketing channel.Here is the table of correspondance between AT Internet source and mediarithmics channel origin field

| source | channel       |
| ------ | ------------- |
| EPR    | $email        |
| EREC   | $email        |
| ES     | $email        |
| AD     | $rtb\_display |
| AL     | $affiliation  |

#### Origin declaration with predefined event properties

When the user event is declared through a tag it is possible to add predefined event properties to declare an activity origin.&#x20;

Here is the list of the predefined properties :

| origin field                    | predefined event properties | example / description                                                                           |
| ------------------------------- | --------------------------- | ----------------------------------------------------------------------------------------------- |
| $source                         | $source                     | $source=crm\_database                                                                           |
| $campaign\_name                 | $campaign\_name             | $campaign\_name=back to school                                                                  |
| $campaign\_technical\_name      | $ctn                        | $ctn=DISPLAY-BACK-TO-SCHOOL                                                                     |
| $campaign\_id                   | $caid                       | $caid=8989                                                                                      |
| $sub\_campaign\_technical\_name | $scatn                      | $scatn=STRATEGY-1, the sub campaign technical name is equivalent to the ad group technical name |
| $sub\_campaign\_id              | $scaid                      | $scaid=8782, sub campaign id is equivalent to the ad group id                                   |
| $creative\_name                 | $creative\_name             |                                                                                                 |
| $creative\_technical\_name      | $crtn                       | $crtn=special-banner                                                                            |
| $keywords                       | $keywords                   | $keywords = sport+shoes                                                                         |
| $social network                 | $social\_network            |                                                                                                 |
| $referral path                  | $referral\_path             |                                                                                                 |
| $log\_id                        | $log\_id                    | unique custom identifier                                                                        |
| $gclid                          | $gclid                      | Google Click Identifier                                                                         |

### Activity unique key

In mediarithmics, each unique activity is stored with 4 different accesses in this order:

Datamart\_id, user\_point\_id, ts and unique\_key.

It means that when those **4 parameters** are identical between 2 activities, the new one cancels and replaces the old one. If one of the parameter differs then a new activity is created.

#### Unique key calculation

This unique key is an uuid format. It can be calculated by the platform or the user itself.

The best practice is to used uuid-v1 when generated by the user as it’s not a random value but calculated on the timestamp and a unique String.

* &#x20;**mediarithmics tag through user-event-front**: the unique\_key is generated by the platform.
* **mediarithmics apis through datamart-front**: the unique\_key can be calculated by the user. If empty, it’s generated by the platform.
* **mediartihmics document import**: the unique\_key can be calculated by the user. If empty, it’s generated by the platform.

When generated manually, the user has to select a key property (such as an order\_id, a unique id generated on client size) or properties concatenation in order for the String to be unique.&#x20;

The uuid-v1 also need a timestamp to be generated and it's highly recommended to select the activity's one.

See additional documentation <https://www.npmjs.com/package/uuid#uuidv1options-buffer-offset>

## User Events object

A User Event is an object composed of an event name and a list of properties. Each property is composed of a name and a value.

```javascript
{
    "$ts": 3489009384393,
    "$event_name": "$transaction_confirmed", // Conversion detected
    "$properties": {
        "$items": [
            {
                 "$id": "product_ID", // Used to filter in funnel analytics
                 "$qty": 20, // Used for conversion amounts
                 "$price": 102.8, // Used or conversion amounts
                 "$brand": "Apple" // Used to filter in funnel analytics
                 "$category1": "Category 1", // Used to filter in funnel analytics
                 "$category2": "Category 2", // Used to filter in funnel analytics
                 "$category3": "Category 3", // Used to filter in funnel analytics
                 "$category4": "Category 4" // Used to filter in funnel analytics
             },
             {
                 "$id": "product_ID2",
                 "$qty": 12,
                 "$price": 3.4,
                 "$brand": "Microsoft"
             }
        ],
        "$currency": "EUR"
    }
}
```

### **Predefined event names**

Using some predefined event names will allow you to have useful adapted automatic processing on some of your events.

| event name              | description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| $page\_view             | <p>The user has viewed a page. <br><br>Events with this event name only serve in session aggregation to have correct information on the user activity. <strong>They will be dropped when the session closes,</strong> and you won't see them on the platform anymore. If you wish to keep a record of the pages a user viewed in your site and create queries based on that data, you should name your event differently. You can also use the <code>$item\_view</code> event name if your pages show products.  </p> |
| $home\_view             | The user has viewed the home page                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| $item\_view             | The user has viewed an item                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| $item\_list\_view       | The user has viewed a list of items                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| $basket\_view           | The user has viewed the basket                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| $transaction\_confirmed | The user has completed a transaction                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| $conversion             | The user has completed a conversion. This event is either registered by the integrator or automatically craeted by the platform when a goal is met.                                                                                                                                                                                                                                                                                                                                                                   |
| $app\_install           | The user has installed an app                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| $app\_update            | The user has updated an app                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| $app\_open              | The user has opened an app or resumed it                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| $ad\_view               | The user has been exposed to a display add                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| $ad\_click              | The user has clicked on an app                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| $email\_view            | The user has opened an email                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| $email\_click           | The user has opened a link in an email                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| $set\_user\_choice      | The user has given consent or objected to a [processing activity](https://developer.mediarithmics.io/advanced-usages/data-privacy-compliance/user-choices#processing-activities)                                                                                                                                                                                                                                                                                                                                      |

{% hint style="warning" %}
**Always prefer predefined event names** to custom events when they exist, as the platform automates a lot of actions based on those names. You could miss some critical steps in having well organized data.
{% endhint %}

### Predefined event properties

Using some predefined event properties will allow you to have useful adapted automatic processing on some of your events.

| property name                   | description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| $items                          | <p>An array of products associated with the event. Mainly used in <a href="../../data-streams/data-ingestion/real-time-user-tracking/web-events#e-commerce-and-products-events">products tracking for e-commerce sites</a>.<br>Example value : <code>\[{"$id":"ProductID1"},{"$id":"ProductID2"}]</code> </p><p></p><p>Each item has the <code>$id</code>, <code>$ean</code>, <code>$qty</code> , <code>$price</code>, <code>$brand</code>, <code>$name</code>, <code>$category1</code>, <code>$category2</code>, <code>$category3</code> and <code>$category4</code>predefined properties.</p> |
| $campaign\_technical\_name      | Technical name of a campaign associated to the event when [tracking ads exposure](https://developer.mediarithmics.io/data-streams/data-ingestion/real-time-user-tracking/ads-exposure).                                                                                                                                                                                                                                                                                                                                                                                                         |
| $sub\_campaign\_technical\_name | Technical name of a sub campaign associated to the event when [tracking ads exposure](https://developer.mediarithmics.io/data-streams/data-ingestion/real-time-user-tracking/ads-exposure).                                                                                                                                                                                                                                                                                                                                                                                                     |
| $creative\_technical\_name      | Technical name of a creative associated to the event                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| $processing\_token              | Token of the associated [processing activity](https://developer.mediarithmics.io/advanced-usages/data-privacy-compliance/user-choices#processing-activities) when event name is `$set_user_choice`.                                                                                                                                                                                                                                                                                                                                                                                             |
| $choice\_acceptance\_value      | Acceptance value of the [user choice](https://developer.mediarithmics.io/advanced-usages/data-privacy-compliance/user-choices#user-choices) when event name is `$set_user_choice`.                                                                                                                                                                                                                                                                                                                                                                                                              |

{% hint style="warning" %}
**Always prefer predefined event properties** to custom event properties when they exist, as the platform automates a lot of actions based on those names. You could miss some critical steps in having well organized data.
{% endhint %}

### User Activity JSON schema and TypeScript interfaces

Below is the JSON schema for a single activity, according to the rules enacted in this documentation.

{% code overflow="wrap" expandable="true" %}

```json
{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "$ref": "#/definitions/UserActivity",
    "definitions": {
        "UserActivity": {
            "oneOf": [
                {
                    "$ref": "#/definitions/GenericUserActivity"
                },
                {
                    "$ref": "#/definitions/SiteVisitUserActivity"
                },
                {
                    "$ref": "#/definitions/AppVisitUserActivity"
                },
                {
                    "$ref": "#/definitions/CTVVisitUserActivity"
                }
            ]
        },
        "GenericUserActivity": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$session_status": {
                    "$ref": "#/definitions/UserActivitySessionStatus"
                },
                "$ttl": {
                    "type": "number"
                },
                "$user_agent_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$user_account_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$compartment_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$email_hash": {
                    "$ref": "#/definitions/Nullable%3Calias-1071211137-70767-70920-1071211137-0-212510%3Cdef-interface-792792747-896-1013-792792747-0-7494%2C%22%24type%22%3E%3E"
                },
                "$user_identifiers": {
                    "$ref": "#/definitions/Nullable%3Cdef-alias-792792747-1226-1323-792792747-0-7494%5B%5D%3E"
                },
                "$origin": {
                    "$ref": "#/definitions/Nullable%3CUserActivityOrigin%3E"
                },
                "$location": {
                    "$ref": "#/definitions/Nullable%3CUserActivityLocation%3E"
                },
                "$unique_key": {
                    "$ref": "#/definitions/UUID"
                },
                "$type": {
                    "type": "string",
                    "enum": [
                        "DISPLAY_AD",
                        "EMAIL",
                        "TOUCH",
                        "USER_SCENARIO_START",
                        "USER_SCENARIO_STOP",
                        "USER_SCENARIO_NODE_ENTER",
                        "USER_SCENARIO_NODE_EXIT"
                    ]
                },
                "$events": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/UserActivityEvent"
                    }
                }
            },
            "required": [
                "$email_hash",
                "$events",
                "$location",
                "$origin",
                "$session_status",
                "$ts",
                "$ttl",
                "$type"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "Timestamp": {
            "type": "number"
        },
        "UserActivitySessionStatus": {
            "type": "string",
            "enum": [
                "NO_SESSION",
                "IN_SESSION",
                "CLOSED_SESSION"
            ]
        },
        "Nullable<ID>": {
            "anyOf": [
                {
                    "$ref": "#/definitions/ID"
                },
                {
                    "type": "null"
                }
            ]
        },
        "ID": {
            "type": "string"
        },
        "Nullable<alias-1071211137-70767-70920-1071211137-0-212510<def-interface-792792747-896-1013-792792747-0-7494,\"$type\">>": {
            "anyOf": [
                {
                    "type": "object",
                    "properties": {
                        "$hash": {
                            "type": "string"
                        },
                        "$email": {
                            "$ref": "#/definitions/Nullable%3Cstring%3E"
                        }
                    },
                    "required": [
                        "$hash"
                    ],
                    "additionalProperties": false
                },
                {
                    "type": "null"
                }
            ]
        },
        "Nullable<string>": {
            "type": [
                "string",
                "null"
            ]
        },
        "Nullable<def-alias-792792747-1226-1323-792792747-0-7494[]>": {
            "anyOf": [
                {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/UserIdentifier"
                    }
                },
                {
                    "type": "null"
                }
            ]
        },
        "UserIdentifier": {
            "anyOf": [
                {
                    "$ref": "#/definitions/UserEmailIdentifier"
                },
                {
                    "$ref": "#/definitions/UserAccountIdentifier"
                },
                {
                    "$ref": "#/definitions/UserAgentIdentifier"
                }
            ]
        },
        "UserEmailIdentifier": {
            "type": "object",
            "properties": {
                "$type": {
                    "type": "string",
                    "const": "USER_EMAIL"
                },
                "$hash": {
                    "type": "string"
                },
                "$email": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                }
            },
            "required": [
                "$type",
                "$hash"
            ],
            "additionalProperties": false
        },
        "UserAccountIdentifier": {
            "type": "object",
            "properties": {
                "$type": {
                    "type": "string",
                    "const": "USER_ACCOUNT"
                },
                "$user_account_id": {
                    "$ref": "#/definitions/ID"
                },
                "$compartment_id": {
                    "$ref": "#/definitions/ID"
                }
            },
            "required": [
                "$type",
                "$user_account_id",
                "$compartment_id"
            ],
            "additionalProperties": false
        },
        "UserAgentIdentifier": {
            "type": "object",
            "properties": {
                "$type": {
                    "type": "string",
                    "const": "USER_AGENT"
                },
                "$user_agent_id": {
                    "$ref": "#/definitions/ID"
                }
            },
            "required": [
                "$type",
                "$user_agent_id"
            ],
            "additionalProperties": false
        },
        "Nullable<UserActivityOrigin>": {
            "anyOf": [
                {
                    "$ref": "#/definitions/UserActivityOrigin"
                },
                {
                    "type": "null"
                }
            ]
        },
        "UserActivityOrigin": {
            "type": "object",
            "properties": {
                "$campaign_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$campaign_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$channel": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$creative_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$creative_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$engagement_content_id": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$gclid": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$keywords": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$log_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$message_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$message_technical_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$referral_path": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$social_network": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$source": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$sub_campaign_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$sub_campaign_technical_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$ts": {
                    "type": "number"
                }
            },
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "Nullable<number>": {
            "type": [
                "number",
                "null"
            ]
        },
        "JsonType": {
            "anyOf": [
                {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                {
                    "type": "boolean"
                },
                {
                    "type": "object"
                },
                {
                    "type": "array",
                    "items": {}
                },
                {
                    "not": {}
                }
            ]
        },
        "Nullable<UserActivityLocation>": {
            "anyOf": [
                {
                    "$ref": "#/definitions/UserActivityLocation"
                },
                {
                    "type": "null"
                }
            ]
        },
        "UserActivityLocation": {
            "type": "object",
            "properties": {
                "$source": {
                    "$ref": "#/definitions/LocationSource"
                },
                "$country": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$region": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$iso_region": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$city": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$iso_city": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$zip_code": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$latlon": {
                    "$ref": "#/definitions/Nullable%3Cnumber%5B%5D%3E"
                }
            },
            "required": [
                "$latlon"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "LocationSource": {
            "type": "string",
            "enum": [
                "GPS",
                "IP",
                "OTHER"
            ]
        },
        "Nullable<number[]>": {
            "anyOf": [
                {
                    "type": "array",
                    "items": {
                        "type": "number"
                    }
                },
                {
                    "type": "null"
                }
            ]
        },
        "UUID": {
            "type": "string",
            "pattern": "^[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12}$"
        },
        "UserActivityEvent": {
            "anyOf": [
                {
                    "$ref": "#/definitions/GenericUserActivityEvent"
                },
                {
                    "$ref": "#/definitions/AdTrackingEvent"
                },
                {
                    "$ref": "#/definitions/SetUserChoiceEvent"
                },
                {
                    "$ref": "#/definitions/SetUserProfilePropertiesEvent"
                },
                {
                    "$ref": "#/definitions/RetailEvent"
                },
                {
                    "$ref": "#/definitions/ConversionEvent"
                }
            ]
        },
        "GenericUserActivityEvent": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$expiration_ts": {
                    "$ref": "#/definitions/Nullable%3CTimestamp%3E"
                },
                "$event_name": {
                    "anyOf": [
                        {
                            "$ref": "#/definitions/EventName"
                        },
                        {
                            "type": "string"
                        }
                    ]
                },
                "$properties": {
                    "$ref": "#/definitions/Customizable"
                }
            },
            "required": [
                "$event_name",
                "$properties",
                "$ts"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "Nullable<Timestamp>": {
            "anyOf": [
                {
                    "$ref": "#/definitions/Timestamp"
                },
                {
                    "type": "null"
                }
            ]
        },
        "EventName": {
            "anyOf": [
                {
                    "$ref": "#/definitions/DefaultEventName"
                },
                {
                    "type": "string"
                }
            ]
        },
        "DefaultEventName": {
            "type": "string",
            "enum": [
                "$page_view",
                "$home_view",
                "$category_view",
                "$email_view",
                "$email_click",
                "$email_sent",
                "$email_delivered",
                "$email_soft_bounce",
                "$email_hard_bounce",
                "$email_unsubscribe",
                "$email_complaint",
                "$content_corrections"
            ]
        },
        "Customizable": {
            "type": "object",
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "AdTrackingEvent": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$expiration_ts": {
                    "$ref": "#/definitions/Nullable%3CTimestamp%3E"
                },
                "$event_name": {
                    "type": "string",
                    "enum": [
                        "$ad_view",
                        "$ad_click"
                    ]
                },
                "$properties": {
                    "$ref": "#/definitions/AdTrackingEventProperties"
                }
            },
            "required": [
                "$event_name",
                "$properties",
                "$ts"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "AdTrackingEventProperties": {
            "type": "object",
            "properties": {
                "$url": {
                    "type": "string"
                },
                "$referrer": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$campaign_technical_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$sub_campaign_technical_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$creative_technical_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$message_technical_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$campaign_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$sub_campaign_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$message_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$creative_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                }
            },
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            },
            "required": [
                "$url"
            ]
        },
        "SetUserChoiceEvent": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$expiration_ts": {
                    "$ref": "#/definitions/Nullable%3CTimestamp%3E"
                },
                "$event_name": {
                    "type": "string",
                    "const": "$set_user_choice"
                },
                "$properties": {
                    "$ref": "#/definitions/SetUserChoiceEventProperties"
                }
            },
            "required": [
                "$event_name",
                "$properties",
                "$ts"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "SetUserChoiceEventProperties": {
            "type": "object",
            "properties": {
                "$url": {
                    "type": "string"
                },
                "$referrer": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$processing_token": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$processing_id": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$choice_acceptance_value": {
                    "type": "boolean"
                },
                "$choice_source_id": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                }
            },
            "required": [
                "$choice_acceptance_value",
                "$url"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "SetUserProfilePropertiesEvent": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$expiration_ts": {
                    "$ref": "#/definitions/Nullable%3CTimestamp%3E"
                },
                "$event_name": {
                    "type": "string",
                    "const": "$set_user_profile_properties"
                },
                "$properties": {
                    "$ref": "#/definitions/Customizable"
                }
            },
            "required": [
                "$event_name",
                "$properties",
                "$ts"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "RetailEvent": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$expiration_ts": {
                    "$ref": "#/definitions/Nullable%3CTimestamp%3E"
                },
                "$event_name": {
                    "$ref": "#/definitions/RetailEventName"
                },
                "$properties": {
                    "$ref": "#/definitions/RetailEventProperties"
                }
            },
            "required": [
                "$event_name",
                "$properties",
                "$ts"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "RetailEventName": {
            "type": "string",
            "enum": [
                "$item_view",
                "$item_list_view",
                "$product_view",
                "$product_list_view",
                "$basket_view",
                "$transaction_confirmed"
            ]
        },
        "RetailEventProperties": {
            "type": "object",
            "properties": {
                "$url": {
                    "type": "string"
                },
                "$referrer": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$items": {
                    "$ref": "#/definitions/Nullable%3Cdef-interface-792792747-3521-3897-792792747-0-7494%5B%5D%3E"
                }
            },
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            },
            "required": [
                "$url"
            ]
        },
        "Nullable<def-interface-792792747-3521-3897-792792747-0-7494[]>": {
            "anyOf": [
                {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/RetailEventPropertiesItem"
                    }
                },
                {
                    "type": "null"
                }
            ]
        },
        "RetailEventPropertiesItem": {
            "type": "object",
            "properties": {
                "$id": {
                    "type": "string"
                },
                "$ean": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$qty": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$price": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$brand": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$category1": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$category2": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$category3": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$category4": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                }
            },
            "required": [
                "$id"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "ConversionEvent": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$expiration_ts": {
                    "$ref": "#/definitions/Nullable%3CTimestamp%3E"
                },
                "$event_name": {
                    "type": "string",
                    "const": "$conversion"
                },
                "$properties": {
                    "$ref": "#/definitions/ConversionEventProperties"
                }
            },
            "required": [
                "$event_name",
                "$properties",
                "$ts"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "ConversionEventProperties": {
            "type": "object",
            "properties": {
                "$conversion_id": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$goal_id": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$conversion_technical_id": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$goal_technical_id": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$conversion_value": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$log_id": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$conversion_external_id": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                },
                "$goal_technical_name": {
                    "$ref": "#/definitions/Nullable%3Cstring%3E"
                }
            },
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "SiteVisitUserActivity": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$session_status": {
                    "$ref": "#/definitions/UserActivitySessionStatus"
                },
                "$ttl": {
                    "type": "number"
                },
                "$user_agent_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$user_account_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$compartment_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$email_hash": {
                    "$ref": "#/definitions/Nullable%3Calias-1071211137-70767-70920-1071211137-0-212510%3Cdef-interface-792792747-896-1013-792792747-0-7494%2C%22%24type%22%3E%3E"
                },
                "$user_identifiers": {
                    "$ref": "#/definitions/Nullable%3Cdef-alias-792792747-1226-1323-792792747-0-7494%5B%5D%3E"
                },
                "$origin": {
                    "$ref": "#/definitions/Nullable%3CUserActivityOrigin%3E"
                },
                "$location": {
                    "$ref": "#/definitions/Nullable%3CUserActivityLocation%3E"
                },
                "$unique_key": {
                    "$ref": "#/definitions/UUID"
                },
                "$session_duration": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$error_analyzer_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$analyzer_errors": {
                    "type": "array",
                    "items": {
                        "type": "object"
                    }
                },
                "$topics": {
                    "$ref": "#/definitions/Nullable%3Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Cnumber%3E%3E%3E"
                },
                "$type": {
                    "type": "string",
                    "const": "SITE_VISIT"
                },
                "$events": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/UserActivityEvent"
                    }
                },
                "$site_id": {
                    "$ref": "#/definitions/ID"
                }
            },
            "required": [
                "$email_hash",
                "$events",
                "$location",
                "$origin",
                "$session_status",
                "$site_id",
                "$ts",
                "$ttl",
                "$type"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "Nullable<alias-1071211137-70404-70537-1071211137-0-212510<string,alias-1071211137-70404-70537-1071211137-0-212510<string,number>>>": {
            "anyOf": [
                {
                    "type": "object",
                    "additionalProperties": {
                        "type": "object",
                        "additionalProperties": {
                            "type": "number"
                        }
                    }
                },
                {
                    "type": "null"
                }
            ]
        },
        "AppVisitUserActivity": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$session_status": {
                    "$ref": "#/definitions/UserActivitySessionStatus"
                },
                "$ttl": {
                    "type": "number"
                },
                "$user_agent_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$user_account_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$compartment_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$email_hash": {
                    "$ref": "#/definitions/Nullable%3Calias-1071211137-70767-70920-1071211137-0-212510%3Cdef-interface-792792747-896-1013-792792747-0-7494%2C%22%24type%22%3E%3E"
                },
                "$user_identifiers": {
                    "$ref": "#/definitions/Nullable%3Cdef-alias-792792747-1226-1323-792792747-0-7494%5B%5D%3E"
                },
                "$origin": {
                    "$ref": "#/definitions/Nullable%3CUserActivityOrigin%3E"
                },
                "$location": {
                    "$ref": "#/definitions/Nullable%3CUserActivityLocation%3E"
                },
                "$unique_key": {
                    "$ref": "#/definitions/UUID"
                },
                "$session_duration": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$error_analyzer_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$analyzer_errors": {
                    "type": "array",
                    "items": {
                        "type": "object"
                    }
                },
                "$topics": {
                    "$ref": "#/definitions/Nullable%3Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Cnumber%3E%3E%3E"
                },
                "$type": {
                    "type": "string",
                    "const": "APP_VISIT"
                },
                "$events": {
                    "type": "array",
                    "items": {
                        "anyOf": [
                            {
                                "$ref": "#/definitions/UserActivityEvent"
                            },
                            {
                                "$ref": "#/definitions/AppActivityEvent"
                            }
                        ]
                    }
                },
                "$app_id": {
                    "$ref": "#/definitions/ID"
                }
            },
            "required": [
                "$app_id",
                "$email_hash",
                "$events",
                "$location",
                "$origin",
                "$session_status",
                "$ts",
                "$ttl",
                "$type"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
		"CTVVisitUserActivity": {
            "type": "object",
            "properties": {
                "$ts": {
                    "$ref": "#/definitions/Timestamp"
                },
                "$session_status": {
                    "$ref": "#/definitions/UserActivitySessionStatus"
                },
                "$ttl": {
                    "type": "number"
                },
                "$user_agent_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$user_account_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$compartment_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$email_hash": {
                    "$ref": "#/definitions/Nullable%3Calias-1071211137-70767-70920-1071211137-0-212510%3Cdef-interface-792792747-896-1013-792792747-0-7494%2C%22%24type%22%3E%3E"
                },
                "$user_identifiers": {
                    "$ref": "#/definitions/Nullable%3Cdef-alias-792792747-1226-1323-792792747-0-7494%5B%5D%3E"
                },
                "$origin": {
                    "$ref": "#/definitions/Nullable%3CUserActivityOrigin%3E"
                },
                "$location": {
                    "$ref": "#/definitions/Nullable%3CUserActivityLocation%3E"
                },
                "$unique_key": {
                    "$ref": "#/definitions/UUID"
                },
                "$session_duration": {
                    "$ref": "#/definitions/Nullable%3Cnumber%3E"
                },
                "$error_analyzer_id": {
                    "$ref": "#/definitions/Nullable%3CID%3E"
                },
                "$analyzer_errors": {
                    "type": "array",
                    "items": {
                        "type": "object"
                    }
                },
                "$topics": {
                    "$ref": "#/definitions/Nullable%3Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Calias-1071211137-70404-70537-1071211137-0-212510%3Cstring%2Cnumber%3E%3E%3E"
                },
                "$type": {
                    "type": "string",
                    "const": "CTV_VISIT"
                },
                "$events": {
                    "type": "array",
                    "items": {
                        "anyOf": [
                            {
                                "$ref": "#/definitions/UserActivityEvent"
                            },
                            {
                                "$ref": "#/definitions/AppActivityEvent"
                            }
                        ]
                    }
                },
                "$ctv_id": {
                    "$ref": "#/definitions/ID"
                }
            },
            "required": [
                "$ctv_id",
                "$email_hash",
                "$events",
                "$location",
                "$origin",
                "$session_status",
                "$ts",
                "$ttl",
                "$type"
            ],
            "additionalProperties": {
                "$ref": "#/definitions/JsonType"
            }
        },
        "AppActivityEvent": {
            "type": "object",
            "properties": {
                "$event_name": {
                    "type": "string",
                    "enum": [
                        "$app_open",
                        "$app_update",
                        "$app_install"
                    ]
                },
                "$properties": {
                    "$ref": "#/definitions/Customizable"
                }
            },
            "required": [
                "$event_name",
                "$properties"
            ],
            "additionalProperties": false
        }
    }
}

```

{% endcode %}
