Get interaction events
Events are available on the Events property of the Interaction object. Every interaction has at least one event.
Get events by type
The following example demonstrates how to retrieve a list of Goal events that occurred during an interaction, ordered by timestamp:
Get events by definition ID
To get a specific goal, outcome, or page event, you can filter by the event’s DefinitionId property. This property is the ID of the definition item in Sitecore that was used when triggering the event.
Some event models, such as DownloadEvent, have a fixed definition ID that is used every time the event is triggered - this means that there is a one to one relationship between the event model and the event definition. The Goal event model, however, can be used with any goal definition item.
In the following examle, every goal with the definition ID {A4364105-1F45-E611-82E6-34E6D7117DCB} is selected.
Get page view events
For web interactions, page views are represented by the PageViewEvent model. The following example demonstrates how to retrieve a list of PageViewEvent events:
Get page view by sequence number
There is no direct replacement for VisitPageIndex. Order page views by Timestamp use the ElementAt() extension. For example:
Get an event that occurred on a specific page
When a contact visits a page, they will trigger a PageViewEvent. In the context of that page, they may also trigger an additional event, such as:
GoalOutcomeDownloadEventSearchEventCampaignEvent- A page event represented by a generic
Event
If an event is triggered in the context of a page, the ParentEventId of that event is the Id of the PageViewEvent. The example below demonstrates how to iterate through a list of pages and get all events that were triggered on that page.
Get page events that are not represented by a custom type
Certain page events are represented by a custom type - such as DownloadEvent. If an event is not represented by a custom type, use the base Event type and filter by the definition ID of the event:
Get campaign event by campaign ID
The CampaignEvent has two definition IDs:
DefinitionIdis the ID of the event definition item itself - this ID is always the sameCampaignDefinitionIdis the ID of the campaign definition item - this ID varies depending on the campaign that was triggered
In the following example, events referencing a campaign with the ID {29814105-2345-E611-AAE6-34E6D7117DCB} are selected:
Get definition item associated with an event or campaign
In a Sitecore context, you can use the Marketing Operations API to retrieve an event or campaign definition item. In a non-Sitecore context, use the Reference Data Service Client API.
It is possible to trigger an event with a random GUID. However, this will adversely affect reporting.