pagent:event bus on the window object and receive all events that pagent is tracking or creating.
Here is an example:
Note: If no session is active, pagent will not emit any events on the pagent:event bus.
Event types
Below is an overview of all event kinds that pagent emits.Event kind | Description |
|---|---|
| click | Fired whenever the visitor clicks anywhere on the page. |
| page_view | Fired each time a page is loaded or navigated to. |
| opt_in | Fired when the visitor explicitly opts-in to tracking. |
| opt_out | Fired when the visitor opts-out of tracking. |
| conversion | Fired when a conversion goal is recorded. |
| session_start | Fired the moment a new session begins. |
| session_end | Fired when the current session is terminated. |
| error | Fired whenever an error occurs while running pagent. |
| highlight_text | Fired when pagent highlights text on the page. |
| element_view | Fired when a tracked element scrolls into the viewport. |
| hover | Fired when the visitor hovers over a tracked element. |
| session_ping | Sent periodically while a session is active to keep it alive. |
Common properties
The following attributes are included in every event:| Property | Type | Description |
|---|---|---|
| session_id | string | Unique identifier of the current session. |
| visit_id | string | Unique identifier of the current page view. |
| time | number | Unix timestamp in milliseconds when the event occurred. |
| is_unique | boolean (optional) | true if this is the first time this event type was emitted during the session. |
| is_opted_in | boolean | Indicates whether the visitor has opted-in to tracking. |
| session_duration | number | Session duration in milliseconds at the moment the event was emitted. |
| scroll_depth | number | Maximum vertical scroll position in pixels that the visitor has reached so far. |
| scroll_percentage | number | Percentage of the page that has been scrolled. |
| url | string | Absolute URL of the page where the event happened. |
session_start properties
Thesession_start event is the one that carries the visitor’s experiment context. When the
visitor is enrolled in a running test, it includes the following additional properties (alongside
the common properties above):
| Property | Type | Description |
|---|---|---|
| experiment_id | string (optional) | The experiment UUID. |
| experiment_numeric_id | number (optional) | The sequential test number shown in the pagent dashboard as “Test #N” (for example, 27). Useful for building human-readable names. |
| variation_id | string (optional) | UUID of the variation assigned to this visitor. |
| is_control | boolean (optional) | true if the visitor is in the control group, false if in a variant. |
| endpoint_id | string (optional) | UUID of the targeted endpoint. |
| endpoint_path | string (optional) | The path the test is configured to target, for example /pricing. For tests targeting a URL pattern (glob), this may be the pattern rather than the exact visited URL. |
| cohort_id | string (optional) | UUID of the cohort the visitor belongs to. |
| cohort_version | number (optional) | Version of the cohort definition. |
Note: All of these experiment fields are absent (ornull) when there is no active pagent test on the current page — for example analytics-only sessions or visitors not enrolled in any running test. Always checkevent.experiment_idbefore reading the others, as the JENTIS example below does.
Example integration
You can also forward individual pagent events to other analytics platforms. The following example shows how to send the conversion event to JENTIS using its push-based data layer:conversion event and immediately submits it to JENTIS.