Session Events
The Send2CRM client records visitor activity within a Session using Events.
Event types are identified by a unique code, and each may store different information. Built-in support is provided for PAGE, FRAGMENT, and GOAL types, along with 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
The send2crm client 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 send2crm library function:
send2crm.analytics?.setGoalsFromDomElements(document);
You may substitute document
for any valid DOM Element to check only a subset of the page elements. A CSS class is applied to processed elements to avoid duplicates.
Programmatic Goals
If you’d like to trigger GOAL Events from custom JavaScript, simply call the send2crm library function:
send2crm.analytics?.setGoal('GoalName2', 5);
Custom Events
An event of any type can be added to the current session by calling the send2crm library function:
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.