Reterive Value from Custom Code | Community
Skip to main content
MktgCloudUser
Level 4
Oct 10, 2018 2:19 AM UTC
Solved

Reterive Value from Custom Code

Hello,

I'm using the Adobe Analytics "Set Variables" action and I have a variable in the Custom Code section.   How do I get the variable from the Custom Code and assign it to any of the evars, props, etc. in the UI? So if I have this:

var loc = 'florida';

what is the code I use to assign the value in the UI (not via code)?  %this.loc% doesn't work.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Gigazelle
GigazelleAccepted solution
Employee
Oct 19, 2018 12:00 AM UTC

As Andrey Osadchuk​ mentioned, custom code is run after the UI.

A way around this would be to have multiple "Analytics - Set Variables" in a rule. have the first one execute the custom code, then the second rule use the UI to set the variables.

4 replies

Gigazelle
GigazelleAccepted solution
Employee
Oct 19, 2018 12:00 AM UTC

As Andrey Osadchuk​ mentioned, custom code is run after the UI.

A way around this would be to have multiple "Analytics - Set Variables" in a rule. have the first one execute the custom code, then the second rule use the UI to set the variables.

Translate
Andrey_Osadchuk
Level 10
Oct 11, 2018 9:42 AM UTC

MktgCloudUser, I have not checked this but it may not work just because the custom code is executed after the UI. If it's possible in your scenario, move your code from the "Custom code" to "Conditions" that have precedence. Let me know if that helped.

Translate
MktgCloudUser
Level 4
Oct 11, 2018 12:27 AM UTC

Doesn't seem to work - the string literal %user_location% is passed.  Also tried %this.user_location%.

Translate
Level 2
Oct 10, 2018 11:56 PM UTC

You could set the element inside your custom code like this:

_satellite.setVar("user_location","florida");

to retrieve it to set the analytics call you can reference it like this %user_location%

Translate