Expand my Community achievements bar.

Applications for the 2024 Adobe Target Community Mentorship Program are open! Click to the right to learn more about participating as either an Aspirant, to professionally level up with a new Certification, or as a Mentor, to share your Adobe Target expertise and inspire through your leadership! Submit your application today.
SOLVED

Is it possible to access mbox / user profile data through JavaScript?

Avatar

Level 1

I'm trying to work with user profile data (category affinity specifically) to implement a custom solution. I'm wondering if it's possible to read that data using JavaScript rather than using Target's built-in category affinity options. I can see this data in the mbox JSON file that's being loaded on our site if I enable the Target trace, but I haven't found a way to access that data programmatically.

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @amberb67455123,

Are you trying to get a visitor's category affinity value back to the page so you can run some client-side JS with it? If that is what you are trying to do you can create a custom modification offer in the VEC that writes a script back to the page and sets the category affinity value to some JS variable. To write Target profile values into experience content/offers see this help doc: https://experienceleague.adobe.com/docs/target/using/experiences/offers/passing-profile-attributes-t.... I think the way to pass category affinity would be with: ${user.endpoint.categoryAffinity}. So you could create a custom modification like this:

 

<script>var catAff = "${user.endpoint.categoryAffinity}";</script>

 

And then your client-side JS could reference the catAff value as needed.

View solution in original post

7 Replies

Avatar

Correct answer by
Employee Advisor

Hi @amberb67455123,

Are you trying to get a visitor's category affinity value back to the page so you can run some client-side JS with it? If that is what you are trying to do you can create a custom modification offer in the VEC that writes a script back to the page and sets the category affinity value to some JS variable. To write Target profile values into experience content/offers see this help doc: https://experienceleague.adobe.com/docs/target/using/experiences/offers/passing-profile-attributes-t.... I think the way to pass category affinity would be with: ${user.endpoint.categoryAffinity}. So you could create a custom modification like this:

 

<script>var catAff = "${user.endpoint.categoryAffinity}";</script>

 

And then your client-side JS could reference the catAff value as needed.

Avatar

Level 1
That's exactly what I'm trying to do, thanks! This all makes sense but when I try to implement it, the script shows up under "AT: Failed actions" in the console and does not run (so the variable is not available for client side code). I was able to see the category affinity when adding it in HTML (wrapped in <p>), but for some reason when trying to assign it to a variable in JavaScript it is failing. The code I used is exactly what you have above, and I added it as a custom code modification in an XT activity. If you have any ideas on how to get past this issue, that would be great! If not, thanks for pointing me in the right direction.

Avatar

Employee Advisor

Ah...so AT: Failed actions often means there is an error in the JS. Reviewing my sample above I see the error. I didn't put quotes around the category affinity. I've correct the original response.

Avatar

Level 1
@Ryan_Roberts_ similar is it possible to access parameters values using some scripts?

Avatar

Level 1
@Ryan_Roberts_ similar is it possible to access mbox parameters values using scripts? Let's say I have an array in my global mbox storing last three pages viewed by the user. I want to access these values and use it for some other purpose outside of target.