Expand my Community achievements bar.

SOLVED

Using javascript variable in Velocity code in designs

Avatar

Employee Advisor
Hello, I am using velocity code in designs and have the following queries
  • how can i read a user cookie in velocity code?
  • how can i read a variable defined in javascript in velocity code?
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

cookies are stored in browser however design is evaluated at target end. I doubt we can get the cookies in the design or profile script.

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @Mohit_KBansal  did you get the chance to check this help article : https://experienceleague.adobe.com/docs/target/using/recommendations/recommendations-design/customiz...

 

To get the list of  cookies for the request you can try this command : $cookies.all

 

Avatar

Employee Advisor

@ambikaTewari_ATCI 

I have checked this but its does not have any information about cookie.

 

Also $cookies.all or $cookies is throwing parsing error

Avatar

Correct answer by
Community Advisor

cookies are stored in browser however design is evaluated at target end. I doubt we can get the cookies in the design or profile script.

Avatar

Employee Advisor

I am aligned with this. To solve this, I used launch script to pass cookie value to Target, in Velocity i was able to read the value:

${mbox.<cookie name>}

Avatar

Community Advisor and Adobe Champion

Dear @Mohit_KBansal ,

Is your question on reading a cookie in Velocity something to do with Target? I am not sure.

Reading and writing cookies in Velocity code should be possible (link) if Velocity Template supports it.

Target would not have any docs related to it since the ask is related to Velocity; Target just supports Velocity's logic and syntax in recommendations.

Thank You, Pratheep Arun Raj B (Arun) | NextRow Digital | Terryn Winter Analytics