Setting and reading cookies inside Adobe Target

Setting and reading cookies within Adobe Target (Test& Target) is very useful and this quick post explains how to do it. 

Step 1 – first we need to create a profile script attribute. From the main menu: Segments > Profiles > + Create Attribute (script attribute)


Step 2 – Name your Script Attribute, copy the below code and click save:

// run this script only with this mbox
if (mbox.name == "yourPage.html")
{
  // this is how we set cookies in Test& Target
  user.setLocal('foo', 'bar');  

  // this is how we read cookies in Test& Target
  var foo = user.getLocal('foo'); 

  // our foo cookie exists 
  if (foo)
  {
   return foo;
  }
}

Step 3 – switch on your script:


Step 4 – now you can use as targeting in your campaigns: