Skip to main content

Mather Listener

Zuora

Mather Listener

Mather Listener is a product from Mather Economics providing advanced user segmentation and data analysis functionality.

The Zephr Mather Listener integration aims to make Mather Listener segmentation data usable in Zephr rules.

Pre-Requisites

NOTE: If you are using the Zephr CDN, in order to access segment IDs provided by Mather, the extension will need to inject a small script to the browser. To have the script injection feature enabled on your Zephr Organisation, please contact your CSM or Zephr Support. If you are not using the Zephr CDN, you will still be able to POST Mather Segment IDs to an endpoint on the Zephr subdomain for your site. For more details please see the Reference section below.

As a pre-requisite, you will need to have Mather Listener configured and active for your site.

Behaviour

When switched on, an HTTP listener will be registered against any Zephr sites for which you have activated the extension.

Any segments POSTed to this endpoint will become available in a user’s session and therefore usable on the Zephr Rules Canvas for decision making.

If you’re using the Zephr CDN, a small script will be injected into the browser on page load. This script will expect to be able to find Mather Segment IDs in a cookie.

To make any retrieved segments usable in Zephr, the extension will make available 2 additional canvas decision nodes: one taking a raw Mather segment ID and another exposing configured ‘Featured Segments’ that can be chosen from a dropdown.

Configuration

To enable the Mather Listener Extension within Zephr, navigate to Settings > Extensions > Mather Listener. If you cannot see the option in your list of Extensions, email support@zephr.com.

Once on the configuration screen, you’ll see two sections – Script Configuration and Segments.

Script Configuration

In this section, you’ll need to input some values to help configure the script injected to the frontend:

  • Cookie name: e.g. _matherListener
  • Polling interval: the gap left by the script between attempts to read the named cookie
  • Max retries: maximum number of times the script will attempt to read the cookie on a given page load

Mather-Listener-Script-Configuration.png

Once the information is completed, click Done.

Segments

The Segments tab takes a single input which is a flat JSON object where the keys are Mather segment IDs and the values are human-readable labels for those segments, to be displayed on the ‘featured segments’ decision node dropdown.

The format is as follows:

{
    "seg1": "Segment 1",
    "seg2": "Segment 2",
    "seg3": "Segment 3"
}

Mather-Listener-Segments.png
Once added, click Save.

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.

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

Usage

Once configured and activated, the extension should automatically take care of adding any retrieved segments to a user’s session information.

To use the extension decision nodes, navigate to the relevant Feature or Redirect Rule, and select the Mather Listener tab from the Rules Palette.  This tab will only be visible once the extension is active.

When you drag a decision node to the canvas, you will need to input a segment: membership of which will form the basis of the decision made by the node.

For the Manual Segment node, you will need to add the raw Mather Segment ID.

For the ‘Featured Segments’ node, you will need to select from a list of pre-configured segments.

Reference

The script that is injected to the front end will vary slightly, depending on your chosen configuration values. It will look similar to:

<script>
(function postSegmentsWhenReady(maxRetries) {
       if (!maxRetries) {
             console.log('Max retries for fetching cookie exhausted');
       } else {
             var pollingInterval = 500;
             if (document.cookie.indexOf('_matherSegments') === -1) {
                   console.log('Waiting for segments in cookie');
                   --maxRetries
                   setTimeout(postSegmentsWhenReady, pollingInterval, maxRetries);
             } else {
                   console.log('Segments available... posting');

                   var getMatherSegments = function (acc, current) {
                         var cookiePair = current.trim().split('=');
                         if(cookiePair[0] === '_matherSegments') {
                               cookiePair[1].split(',').forEach(function (value) {
                                     acc.push(value);
                               });
                         }
                         return acc;
             }

             var segments = document.cookie.split(';').reduce(getMatherSegments, []);

             console.log(segments);
             var retrieveSegmentsXhr = new (XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0');
             retrieveSegmentsXhr.open('POST', '/plugins/public/mather-listener/segments', true);
             retrieveSegmentsXhr.setRequestHeader('Content-type', 'application/json');
             retrieveSegmentsXhr.withCredentials = true;
             retrieveSegmentsXhr.send(JSON.stringify(segments));
       }
    }
})(10);
</script>

If you are not using the Zephr CDN, you can still use your own script to POST segment IDs to Zephr.

You will need to POST the segments to the Zephr subdomain for your site (visible in the Zephr Admin Console).

Please remember to include:

  • A valid session ID for your user in the `Cookie` header – e.g. Cookie: blaize_session=70635d53-b265-4156-bd8d-ec479a95dec5
  • Any segments that you retrieved from Mather should be included in the request body as a stringified JSON array of strings.