S4S Cloud records visitor activity within a Session using Events.
Event types are identified by a unique code, and each may store different information. S4S Cloud has built-in support for PAGE, FRAGMENT, and GOAL types, and supports the programmatic setting of any other custom type. All Event types record the type code and time of the activity.
PAGE and FRAGMENT
PAGE events are recorded when:
A page is shown due to normal navigation or refresh (pageshow event).
Forward or back navigation is used (popstate event).
JavaScript navigation via
history.pushState()
orhistory.replaceState()
occurs.
FRAGMENT events are recorded when:
A page fragment is navigated to (hashchange event).
PAGE and FRAGMENT events record the href, and the referrer and title where available.
GOAL
GOAL events are a means of scoring visitor interactions in different ways, and assigning values that can be used to later personalize the visitor’s experience.
GOAL events record a name and numeric value. They also trigger an automatic roll-up to the summary values on the Visitor data.
Automatic Goals
S4S Cloud automatically checks the document for elements that include Goal attributes on the load event. If you wish for a Goal to be registered, simply add the data-goalname and data-goalvalue attributes to any element in the document, e.g.:
<div data-goalname="GoalName1" data-goalValue="10"></div>
If you need to trigger a re-check of the DOM after page load (e.g. due to AJAX content loading) you can call the S4S Cloud library function:
S4SCloud.analytics?.setGoalsFromDomElements(document);
You may substitute document
for any valid DOM Element to check only a subset of the page elements. S4S Cloud applies a class to processed elements to avoid duplicates.
Programmatic Goals
If you’d like to trigger GOAL Events from custom JavaScript, simply call the S4S Cloud library function:
S4SCloud.analytics?.setGoal('GoalName2', 5);
Custom Events
An event of any type can be added to the current session by calling the S4S Cloud library function:
let eventData = { customProperty1: 'customvalue1', customProperty2: 'customvalue2', }; S4SCloud.analytics?.setCustomEvent('CUSTOMTYPE', eventData);
Pick a unique type code for later identifying your custom event, and pass in an object containing any custom properties desired. The type and time properties will be added automatically.