-
Notifications
You must be signed in to change notification settings - Fork 0
Using Lytics segment API
Maciek Jurczyk edited this page Feb 17, 2016
·
4 revisions
Instead of displaying widgets to all users, one can use targeted widgets which will be displayed only to a specific user group.
To do so, instead of widget array, one needs to add add ‘target’ object, in addition to Lytics ID.
In example below message1 will be displayed to new users (classified by Lytics as smt_new
, and message2 will be visible for subscribers.
Widgets inside common
array are visible by all users.
Widgets inside inverse
are visible to any users who are not a member of smt_new
or subscribers
.
var message1 = new pathfora.Message({
msg: 'Welcome to our site',
layout: 'modal'
});
var message2 = new pathfora.Message({
msg: 'Nice to see you again',
layout: 'modal'
});
var message3 = new pathfora.Message({
msg: 'This message is visible by all users',
layout: 'modal'
});
var message4 = new pathfora.Message({
msg: 'This message is visible by users who are not a part of either segment',
layout: 'bar'
});
var message5 = new pathfora.Message({
msg: 'This message is visible by all users',
layout: 'bar'
});
var widgets = {
target: [
{
segment: 'smt_new',
widgets: [message1]
},
{
segment: 'subscribers',
widgets: [message2]
},
{
segment: '*', // Wildcard segment allows all users to see the widget
widgets: [message3]
}
],
inverse: [message4],
common: [message5]
};
var lyticsId = '1234';
pathfora.initializeWidgets(widgets, lyticsId);