The browser’s local Facet values are updated from the response when a service synch occurs.
Applying Facets
To ensure the correct timing when making alterations handle the S4SCloudLoading event in your own script:
window.addEventListener('S4SCloudLoading', (evt) => { // Facet evaluation code goes here. });
Set a Facet for the Goal threshold
Facets may be applied when the Visitor reaches a threshold value for a particular Goal.
// Apply the Personalization facet 'VIP_VISITOR' when the 'IMPORTANT_GOAL' Goal value reaches 50 total for the Visitor. S4SCloud.personalization.setFacetForGoal('VIP_VISITOR', 'IMPORTANT_GOAL', 50);
S4S Cloud will automatically set the Facet when the specified Goal reaches the given value.
Set a Facet using Custom Logic
Facets may also be applied using your own logic. This uses a callback function that provides the current Visitor object.
// Apply the Personalization facet 'REPEAT_VISITOR' when the Visitor has more than one Session. S4SCloud.personalization.setFacetWhen('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 should be applied.
Retrieving Facets
Use the values of saved Facets to determine when you want to apply Personalization to your website.
Testing
To check whether a Visitor has a Facet applied, call the S4S Cloud library function:
if (S4SCloud.personalization.hasFacet('VIP_VISITOR')) { // Do something special. }
Persistence
Facets are recorded against the Visitor, they are never removed once applied. They are also sent to the S4S Cloud service for Identified Visitors and synchronized across different browsers.
Facet Cookie
If the personalizationCookie setting is enabled, S4S Cloud will automatically populate a cookie named S4SCloud with the values of all Facets separated by pipe (|) characters. e.g.:
|REPEAT_VISITOR|VIP_VISITOR|
This allows accessing the values of applied Facets server-side on your website.
Standard requirements for user acceptance of cookies apply. You may need to implement a suitable notice on your website if not already in place.