Expand my Community achievements bar.

Launch an activity if a cookie is in the page with mbox.js

Avatar

Level 1

Hi all,

I have a question about on how to target and launch an activity if the user has a cookie on his browser.

I already saw different solutions but apparently any on those seems to work to me, probably I'm missing something.

Could someone explain me step by step what it needs to be done?

Please be aware that this will need to work with mbox.js (so not at.js).


Thank you so much,
Renato

5 Replies

Avatar

Level 3

Hi renatob2547702 ,

You could also set cookie using profile script for the targeted page and then use it in audience..

you can find the code for setting cookie in help section if not use the below code :

if (mbox.name == "xy")

{

  // this will set cookie

  user.setLocal('product', 'zz');

  // this is how we read cookies in Test& Target

  var zz = user.getLocal('zz');

  // cookies exist

  if (zz)

  {

  return zz;

  }

}

and then pass the value in audience . user.cookie equals - product

In case you are looking for cookie from other source.. you could use [Not sure if this works i have not tried it, though you could give it a try]

if(document.cookie = "Cookie name") {

// your code

}

Hope this was helpful

Avatar

Level 1

Hi Yogita, thank you so much for your answer.


I suppose I have to paste the code you wrote inside a profile script.

Question now are:


Since I have only to read the cookie, I think I can remove the line:

// this will set cookie

  user.setLocal('product', 'zz');

Is this correct?


Also, what are exactly "product" and "zz"? It seems like I have to replace these.

Then, when creating the audience based on a visitor profile (so passing a value for the "equals" condition), which value should I pass, product or zz?
If "product", why on the 'read the cookie' code I pass only "zz"?

I know this could be a little bit much but let me know for any question or clarification.


Thank you again,

Renato

Avatar

Level 3

@renatob25477023 

I am afraid i am not completely aware if you  could read the cookies locally stored in the "browser" with the help of profile script.

We will have to find that out.

You can also go with the second approach ..

you can simply add the condition in your campaign code.

if(document.cookie = "Cookie name") {

// your code

}

1366525_pastedImage_2.png

I would suggest you to try this approach. This will solve your problem without modifying the audience.

Avatar

Level 1

Hey, thanks for your reply.

Yes, that's what I can not find yet as well.

About last code you sent me, that will work only for apply/not apply the code inside the experiment. But a user will be bucketed in in any case as the cookie condition is not on the audiences, but only in the activity code (so that's not what I am looking for).

If we could find a way to add a cookie check in the targeting rules should be perfect.

But probably Adobe Target is lacking in this.

Avatar

Community Advisor

I have a question about how the Launch work if we want to fire a rule where either click on accept cookie banner or cookie is already on user browser? what could be the custom code in Launch?