Event Tracking
Tracking events are required in order to send user activity to PureClarity which in turn allows PureClarity to learn about them and thus fit them into PureClarity customer segments allowing personalized and relevant merchandising zones to be displayed within your site. As outlined in the PCJS Master Function section the standard master function snippet has to be added to every page for tracking events to work:PCJS Master Function
_pc(‘page_view’, {…} ) is the first tracking event to be called, and is different for each page in order to add context to what the user is viewing.
Page View Tracking Event
The page_view tracking event can take an optional “context data” object as the second argument, and is used to tell PureClarity which page the user is currently viewing along with contextual information about the page, such as the Id of a product being viewed. This page type and context information is used by PureClarity to influence which zones are returned and what content they may display based on the context. A page_view tracking event with context data is shown below:General Tracking Events
All tracking events are added to the site using the_pc() JavaScript global function. Similarly to the page view tracking event, the following example shows how this should be formatted:
Callback Events
Your own JavaScript function can be called once PureClarity has returned results and rendered zones on the page. This is useful should you wish to manipulate the content or styling of what is returned. For example you could use JQuery to set “live stock” alerts for products in a recommender. The following shows how to implement a callback event:Pre-render Callback Events
Sometimes you might need to initialise the contents of a zone before they are displayed, for example if you are using a custom slider for a product recommender and you want to only initialize it if content is returned. PureClarity supports this by providing theprerender_callback_event. To implement this use the following code snippet:
prerender_callback_event and the callback_event is as follows:
- PureClarity loads the content into the HTML DIV element. (If there is no content to show, then PureClarity will not alter the content of the HTML DIV).
- The prerender_callback_event function is then called.
- PureClarity sets the ‘display’ style of the HTML DIV element to ‘block’
- PureClarity calls the callback_event.
callback_event will be enough. If you want to perform some initialisation before the zone content is made visible then set the style of the block to ‘hidden’ and then subscribe to the prerender_callback_event.