Skip to main content
Mohit_KBansal
Adobe Employee
Adobe Employee
Jun 21, 2023 8:18 AM UTC
Solved

Using javascript variable in Velocity code in designs

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.
ambikaTewari_ATCI
ambikaTewari_ATCIAccepted solution
Community Advisor
Jun 21, 2023 11:37 AM UTC

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.

5 replies

ambikaTewari_ATCI
Community Advisor
Community Advisor
Jun 21, 2023 11:24 AM UTC

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

 

Translate
Mohit_KBansal
Adobe Employee
Adobe Employee
Jun 21, 2023 11:32 AM UTC

@ambikatewari_atci 

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

 

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

Translate
ambikaTewari_ATCI
Community Advisor
ambikaTewari_ATCICommunity AdvisorAccepted solution
Community Advisor
Jun 21, 2023 11:37 AM UTC

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.

Translate
PratheepArunRaj
Adobe Champion, Community Advisor, UG Leader
Adobe Champion, Community Advisor, UG Leader
Jun 21, 2023 12:22 PM UTC

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

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