Skip to main content

Krux

Zuora

Krux

Krux is a DMP owned and operated by Salesforce. Krux allows for the segmentation of users. Using the Zephr/Krux integration allows you to pull these segments into Zephr, for use in Zephr Rules as decision points.

Pre-requisites

NOTE: If you will be serving your site through the Zephr CDN, the Krux integration relies on a Zephr script injection feature (this is where Zephr will deploy a small script to interact with the window.Krux.segments array from the browser. Please contact your Customer Success Manager or Zephr Support to have script injection enabled for your tenant.

  • Krux environment
  • Zephr script injection feature activated (if serving your site through the Zephr CDN)

Behaviour

This extension comprises three main components:

  • A HTTP listener to receive segment data that is activated on your Zephr site(s)
  • A script that is injected to fetch the Krux segment data and POST to the HTTP listener (if you are not using the Zephr CDN, you can still post segment data to this endpoint yourself)
  • A Krux segment decision point node for the Zephr rules canvas

Once the extension is activated, when pages are loaded through the Zephr CDN, a small script is injected into the browser to poll for the window.Krux.segments object.

Once the object is available, any segments that are detected for that user will be posted as a simple array to the HTTP listener and stored in the user’s session.

Once the segments are in the user session, any rule that is evaluated that includes a decision using the Krux segment decision point will take account of the segments.

NOTE: As segments are gathered and posted asynchronously from the browser, it may be that Zephr will not be aware of any segments on the first page load of a fresh session. Also, should the polling interval for the window.Krux.segments object be set to something longer than a given page view for a user, it is possible that no segments will be posted to Zephr for that page view.

Configuring the Krux Extension

To enable the Krux extension within Zephr, navigate to Settings > Extensions and select the Krux option in the Customer Data Platform Extensions section. If you cannot see the Krux extension, please email support@zephr.com.

Script Configuration

Once on the configuration screen, select the Script Configuration tab. Here you will need to choose a suitable interval (in milliseconds) at which the frontend script will poll for the existence of first the window.Krux object, and then the existence of the window.Krux.segments array. This value will default to 200 ms.

Once added, click Done.

Activate Plugin

Once you’ve input the relevant details, confirm which of your Sites the extension should be active on. To do this, use the toggles for each site under the Activate Plugin section, or choose Select All Sites.

Mailchimp - Plugin Activation

Once completed, click Save. Your extension is now enabled.

Example Script

For reference, please an example of the script that is injected to the client-side by the extension (in this instance, configured to poll every 500 ms):

(function postSegmentsWhenReady(maxRetries) {
    if (!maxRetries) {
       console.log('Max retries for fetching Krux segments exhausted');
    } else {
       var pollingInterval = 500;
       if (!window.Krux) {
          console.log('Waiting for Krux object');
          --maxRetries
          setTimeout(postSegmentsWhenReady, pollingInterval, maxRetries);
       } else {
          if (!window.Krux.segments) {
             console.log('Waiting for Krux.segments');
             --maxRetries
             setTimeout(postSegmentsWhenReady, pollingInterval, maxRetries);
          } else {
             console.log('Krux.segments available... posting');
             var segments = window.Krux.segments;
             var retrieveSegmentsXhr = new (XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0');
             retrieveSegmentsXhr.open('POST', '/plugins/public/krux/segments', true);
             retrieveSegmentsXhr.setRequestHeader('Content-type', 'application/json');
             retrieveSegmentsXhr.withCredentials = true;
             retrieveSegmentsXhr.send(JSON.stringify(segments));
          }
       }
    }
})(20);

The script will be inserted, wrapped with a pair of HTML <script> tags, near the end of the HTML document delivered to the browser.

If this script will not be suitable for your purposes, please contact your Zephr Customer Success Manager, or create a ticket for support.