Target users based on cookie value

prajwalreddy 11-09-2018

We have integrated with target using the experience fragments approach. Now, There is requirement to targets users based on the cookie value in the browser. Do we have any approach apart from Target Audience Based on Cookie Value  mbox approach?

Accepted Solutions (1)

Accepted Solutions (1)

Arun_Patidar
MVP
11-09-2018

Hi,

You can go with script reference segment.

Configuring Segmentation with ContextHub

which will uses js to register segment with clientlibs of category 'contexthub.segment-engine.scripts'

There is utility to interact with cookies i.e. ContextHub.Utils.Cookie

ContextHub Javascript API Reference

Example :

ContextHub.console.log(ContextHub.Shared.timestamp(), '[loading] contexthub.segment-engine.scripts - my-audience-segment.js');

(function() {

  var getMySegment = function() {

        var axes4="retail";

        var segAxes4=false;

      /*  if (ContextHub.Utils.Cookie.exists("axes1")) {

  segAxes4=true;

        } */

        if((ContextHub.Utils.Cookie.getItem("axes"))==axes4){

  segAxes4=true;

        }

        return segAxes4;

    };

    /* register function */

    ContextHub.SegmentEngine.ScriptManager.register('My-Retail-Segment', getMySegment);

})();

Answers (6)

Answers (6)

kumar4585 12-02-2019

give some examples regarding cookie based targeting, how to store values in cookies and getting back user data from cookie,

provide any reference links or examples to redirect a page based on location.