Targeting based on a custom cookie value




Could anyone please give me an advice on how to create a segment in T&T based on cookie value?

What I've tried to do is to add an Expression Target:

return document.cookie.replace(/(?:(?:^|.*;\s*)network\s*\=\s*([^;]*).*$)|^.*$/, "$1").toLowerCase().indexOf("par_") != -1

This searches for "par_" string in the cookie "network".

When I try to add this Expression Target I get the following error:
Expression for rule Channel: Partner is not valid: "Syntax or runtime error: ReferenceError: "document" is not defined."

I've looked at the Expression Target documentation ( but I could not find any way of how to create the Expression Target based on the cookie.

Can anyone help, please? Perhaps there are also easier way creating segments based on the cookie value?



Accepted Solutions (1)

Accepted Solutions (1)



See if this helps: 

Option 1: Use the Back-End of your Site to read the cookie and pass some flag to the mboxcreate method during page load. This can be used in the TnT console for targeting.  e.g. 

mboxCreate('orderConfirmPage', parameter=true);

Then, when targeting, if you don't see the mbox parameter in the list, just add it, it should work. 


Option 2: 

- You need to create a plugin-offer that reads the cookie values and stores the values or flags in the profile or user parameters of the mbox with mbox update. You assign this plugin to the desired mbox location. 

- In the targeting options: Visitor Behavior -> YourProfileParameter -> Condition.. 

Answers (0)