Using javascript variable in Velocity code in designs | Community
Skip to main content
Mohit_KBansal
Adobe Employee
Adobe Employee
June 21, 2023
Solved

Using javascript variable in Velocity code in designs

  • June 21, 2023
  • 2 replies
  • 2501 views
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?
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ambikaTewari_ATCI

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.

2 replies

ambikaTewari_ATCI
Community Advisor
Community Advisor
June 21, 2023

Hi @mohit_kbansal  did you get the chance to check this help article : https://experienceleague.adobe.com/docs/target/using/recommendations/recommendations-design/customizing-a-template.html?lang=en

 

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

 

Mohit_KBansal
Adobe Employee
Adobe Employee
June 21, 2023

@ambikatewari_atci 

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

 

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

ambikaTewari_ATCI
Community Advisor
ambikaTewari_ATCICommunity AdvisorAccepted solution
Community Advisor
June 21, 2023

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.

PratheepArunRaj
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
June 21, 2023

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

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