Applying
...
Segments
To ensure the correct timing when making alterations handle the send2crmLoading event in your own script:
Code Block |
---|
window.addEventListener('send2crmLoading', (evt) => { // FacetSegment evaluation code goes here. }); |
Set a
...
Segment for the Goal threshold
Facets Segments may be applied when the visitor reaches a threshold value for a particular Goal.
Code Block | ||
---|---|---|
| ||
// Apply the Personalization facetSegment 'VIP_VISITOR' when the 'IMPORTANT_GOAL' Goal value reaches 50 total for the Visitor. send2crm.personalization.setFacetForGoalsetSegmentForGoal('VIP_VISITOR', 'IMPORTANT_GOAL', 50); |
The Facet Segment will be applied automatically when the specified Goal reaches the given value.
Set a
...
Segment using Custom Logic
Facets Segments may also be applied using your own logic. This uses a callback function that provides the current Visitor object.
Code Block | ||
---|---|---|
| ||
// Apply the Personalization facetSegment 'REPEAT_VISITOR' when the Visitor has more than one Session. send2crm.personalization.setFacetWhensetSegmentWhen('REPEAT_VISITOR', function(visitor) { return (visitor.sessionCount > 1); }); |
See Visitor information for a list of available Visitor properties. The session property contains the current Session object. Use this data to perform your logic and return true
if the Facet Segment should be applied.
Retrieving
...
Segments
Use the values of saved Facets Segments to determine when you want to apply personalization to your website.
Testing
To check whether a visitor has a Facet Segment applied, call the Send2CRM library function:
Code Block | ||
---|---|---|
| ||
if (send2crm.personalization.hasFacethasSegment('VIP_VISITOR')) { // Do something special. } |
Persistence
Facets Segments are recorded against the visitor, and never generally not removed once applied. They are also sent to the Send2CRM service for Identified Visitors and synchronized across different browsers.
...
Segment Cookie
If the personalizationCookie setting is enabled, Send2CRM will automatically populate a cookie named send2crm with the values of all Facets Segments separated by pipe (|) characters. e.g.:
...
This allows accessing the values of applied Facets Segments server-side on your website.
...