How do I capture boolean values from JS varible | Community
Skip to main content
August 19, 2019
Solved

How do I capture boolean values from JS varible

  • August 19, 2019
  • 2 replies
  • 3061 views

I have a data element that is using JavaScript variable name to get a value. The values are boolean.

Is it the case that this field can only return string values? It seems that anytime i try to capture a boolean, the data doesn't appear in the analyics debugger.

Thanks!

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 Andrey_Osadchuk

Hi kshafer42,

Yes, your observation is 100% accurate. The false value will not get populated if set as a reference to a Data Element.

As you already may guess, you can make a transition from boolean to string to make it working. For example, you can create another Data Element that will be mapped to the primary "boolean" Data Element with some JS code that will make the trick.

2 replies

kshafer42Author
August 19, 2019

FUN FACT: if the variable returns "false" it doesn't return any value. Boolean only seems to work if the result it true. Thoughts?

Andrey_Osadchuk
Andrey_OsadchukAccepted solution
August 20, 2019

Hi kshafer42,

Yes, your observation is 100% accurate. The false value will not get populated if set as a reference to a Data Element.

As you already may guess, you can make a transition from boolean to string to make it working. For example, you can create another Data Element that will be mapped to the primary "boolean" Data Element with some JS code that will make the trick.