Expand my Community achievements bar.

SOLVED

Targeting based on a custom cookie value

Avatar

Level 3

Hi,

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 (http://microsite.omniture.com/t2/help/en_US/tnt/pdf/js_expression_cheat_sheet.pdf) 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?

Thanks,

Lucas

1 Accepted Solution

Avatar

Correct answer by
Level 2

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.. 

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

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..