Reterive Value from Custom Code

Avatar

Avatar
Validate 10
Level 2
MktgCloudUser
Level 2

Likes

14 likes

Total Posts

43 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Ignite 1
Give Back
Boost 5
View profile

Avatar
Validate 10
Level 2
MktgCloudUser
Level 2

Likes

14 likes

Total Posts

43 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Ignite 1
Give Back
Boost 5
View profile
MktgCloudUser
Level 2

09-10-2018

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.

evar.jpg

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
Employee
Gigazelle
Employee

Likes

473 likes

Total Posts

1,947 posts

Correct reply

740 solutions
Top badges earned
Coach
Contributor 2
Validate 1
Ignite 80
Ignite 70
View profile

Avatar
Coach
Employee
Gigazelle
Employee

Likes

473 likes

Total Posts

1,947 posts

Correct reply

740 solutions
Top badges earned
Coach
Contributor 2
Validate 1
Ignite 80
Ignite 70
View profile
Gigazelle
Employee

18-10-2018

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.

Answers (3)

Answers (3)

Avatar

Avatar
Shape 25
MVP
Andrey_Osadchuk
MVP

Likes

537 likes

Total Posts

968 posts

Correct reply

263 solutions
Top badges earned
Shape 25
Bedrock
Coach
Boost 500
Affirm 250
View profile

Avatar
Shape 25
MVP
Andrey_Osadchuk
MVP

Likes

537 likes

Total Posts

968 posts

Correct reply

263 solutions
Top badges earned
Shape 25
Bedrock
Coach
Boost 500
Affirm 250
View profile
Andrey_Osadchuk
MVP

11-10-2018

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.

Avatar

Avatar
Validate 10
Level 2
MktgCloudUser
Level 2

Likes

14 likes

Total Posts

43 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Ignite 1
Give Back
Boost 5
View profile

Avatar
Validate 10
Level 2
MktgCloudUser
Level 2

Likes

14 likes

Total Posts

43 posts

Correct reply

2 solutions
Top badges earned
Validate 10
Validate 1
Ignite 1
Give Back
Boost 5
View profile
MktgCloudUser
Level 2

10-10-2018

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

Avatar

Avatar
Validate 1
Level 2
christopher2151
Level 2

Likes

9 likes

Total Posts

15 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 2
christopher2151
Level 2

Likes

9 likes

Total Posts

15 posts

Correct reply

0 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 1
Applaud 5
View profile
christopher2151
Level 2

10-10-2018

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%