Can i get category affinity values in Experiences through code? | Community
Skip to main content
Level 2
June 24, 2022
Solved

Can i get category affinity values in Experiences through code?

  • June 24, 2022
  • 1 reply
  • 1702 views

Hi,

 

I am facing a hard time getting first category, second category etc. values inside experiences through custom code within Adobe target. I can use user.categoryAffinity to get the value in it. But, is there any way to get first category, second category etc values as well by doing something similar ?

 

Thanks in advance.

 

Regards,

Nitish

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 Gaureshk_Kodag

Hi @lambanitish 

 

You can use profile script to fetch category affinity array using "user.categoryAffinities" and then consider first element of array as first favorite category, second as a second and so on. 

 

once you store category affinity array in profile script, fetch it into your code using "${user.profilescriptname}".(double/single quotes are mandatory while fetching profile script value)

 

Hope this helps.

1 reply

Gaureshk_Kodag
Adobe Employee
Gaureshk_KodagAdobe EmployeeAccepted solution
Adobe Employee
June 24, 2022

Hi @lambanitish 

 

You can use profile script to fetch category affinity array using "user.categoryAffinities" and then consider first element of array as first favorite category, second as a second and so on. 

 

once you store category affinity array in profile script, fetch it into your code using "${user.profilescriptname}".(double/single quotes are mandatory while fetching profile script value)

 

Hope this helps.

Level 2
July 11, 2023

How do I tell our developer which fields to use as the category @Gaureshk_Kodag?

 

Say our data layer has two fields:

  1. sections: ['World']
  2. subject: ['NATO''NATO Summit''Politics of Sweden''International agreements''International relations''Politics of Turkey']

When I tell him to pass category as mbox parameter user.categoryId in global mbox on the product page, how does he only populate the affinities with the sections and subject values?

 

Thanks

Gaureshk_Kodag
Adobe Employee
Adobe Employee
July 20, 2023

You could ask your developer to pass the values in a comma separate format.

for example, user.categoryId=world, NATONATO SummitPolitics of SwedenInternational agreementsInternational relationsPolitics of Turkey