Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

Data Element Works only with return Statement

Gianluca
Level 1
Level 1

Hi all,

in Adobe Launch I have defined a data element that should be set with a javascript variable on source page of the website.

When I call on browser console _satellite.getVar('MY VAR') it returns null, even if the javascript variable is defined and populated.

After several tests it seems that I can retrieve my data element value only defining it as a custom code type with a return statement like this:

 

if(MY JAVASCRIPT VARIABLE)

 return MY JAVASCRIPT VARIABLE;

else

return ""

May someone help me understand why?

 

Thank you 

4 Replies
Andrey_Osadchuk
Community Advisor
Community Advisor

Yes, this is how it's designed. What was your expectation?

 

 
yuhuisg
Community Advisor
Community Advisor

Just to confirm: inside Adobe Launch, you have setup a Data Element from Core > JavaScript Variable, and you've specified the name of your JavaScript variable in that data element's configuration, right?

Screenshot 2021-02-19 at 6.20.51 PM.png

Gianluca
Level 1
Level 1
Hi yuhuisg, exactly, I've initially defined the variable as you shown in the screeshoot, but I have no value for that. Instead declaring the same variable but with custom code and the return statement, it works always well.
yuhuisg
Community Advisor
Community Advisor
@Gianluca is the variable set when the page is loaded or later on, e.g. through a script that gets executed after page load? Alternatively, are you able to provide a link to the web page for us to see?