Skip to main content

Events

Events collect data about relevant occurrences in your application. They are either triggered directly when a user interacts with your application (an InteractiveEvent), or automatically, e.g. when a form callback or payments completes at a later time (a NonInteractiveEvent).

Properties

Next to specifying its _type, Events must provide a unique id. Together with its Location Stack, every Event in an application should be unique - Trackers help to enforce this.

Additionally, every Event must have GlobalContexts, with at least an ApplicationContext, to be able to distinguish from what application the event originated.

Every Event optionally can, but most likely will, carry a list of LocationContexts that describe where the event happened

An example event with location_stack and global_context properties:

{
"_type":"ClickEvent",
"id":"211d778b-20ea-4a12-be56-77d5b8fe3cd0"
"location_stack":[
{
"_type":"WebDocumentContext",
"id":"#document",
"url":"https://example.com/path"
},
{
"_type":"SectionContext",
"id":"homepage"
},
{
"_type":"LinkContext",
"id":"link-id",
"text":"Go!",
"href":"/path"
}
],
"global_contexts":[
{
"_type":"ApplicationContext",
"id":"example-website"
},
{
"_type":"DeviceContext",
"id":"device",
"user_agent":"Mozilla/5.0"
}
],
}

Triggers

For tagged Elements, most Events will be triggered automatically, based on the LocationContext bound to the Tagged Element. To do so, internally, the Web tracker uses a Mutation Observer to monitor the DOM. When existing nodes change or get removed, or if subtrees get added, it traverses the Nodes and scouts for Elements that have been enriched with Tracking Attributes. For those Elements it attaches Event listeners, which will automatically handle their tracking.

However, sometimes it may be preferable, or necessary, to trigger Events programmatically.

Out-of-the-box Events

The Tracker uses the same Observer described above to trigger the events below by default.

ApplicationLoaded

An ApplicationLoaded Event (by default enabled, configurable) triggers once on application load.

URLChange

An URLChange Event (by default enabled, configurable) triggers on SPA URL changes, by keeping track of the last URL detected.