Sitecore 8 Register Page Events
A quick Sitecore 8 code sample to demonstrate programatically registering a page event such as an internal search, or a downloaded resource.
- Firstly check whether the tracker is active, and there is a session.
- Get a reference to the current page
- Create an instance of PageEventData, passing in the event name (e.g. Search) and page event guid. The PageEventData exposes:
- itemId - The page item ID that raises the page event.
- Data - Data associated to the event such as search keywords.
- Text - Human readable text to go with the page event, appears as a summary in xProfile e.g. resource downloaded
- Pass the PageEventData into the register method of the current page to register the page event.