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

Track multi choice

Avatar

Avatar
Ignite 1
Level 3
1982luca
Level 3

Likes

6 likes

Total Posts

315 posts

Correct Reply

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

Avatar
Ignite 1
Level 3
1982luca
Level 3

Likes

6 likes

Total Posts

315 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Boost 3
Boost 1
Applaud 5
View profile
1982luca
Level 3

12-12-2020

 

Hello everyone,

 

How can I track multi-choice and have an evar like this Contemporary Arts|Visual Arts.

Thanks

 

1982luca_0-1607783981908.png

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Affirm 50
MVP
evolytics_brian
MVP

Likes

80 likes

Total Posts

170 posts

Correct Reply

54 solutions
Top badges earned
Affirm 50
Applaud 25
Establish
Seeker
Give Back
View profile

Avatar
Affirm 50
MVP
evolytics_brian
MVP

Likes

80 likes

Total Posts

170 posts

Correct Reply

54 solutions
Top badges earned
Affirm 50
Applaud 25
Establish
Seeker
Give Back
View profile
evolytics_brian
MVP

14-12-2020

@1982luca -

I'd probably create a data element in Launch that's based on custom JS (see below). You'd then just reference the data element in the rule that executes when the form is submitted (or whenever you want to collect the info) to populate your eVar (listVar, listProp...).

var retval = [];
var elements = document.querySelectorAll("input[name='interests']");

if (elements.length > 0) {
  elements.forEach(function (item) {
    if ((item).checked === true) {
      var chosenOne = item.parentElement.querySelector("span").innerText;
      if (chosenOne) {
        retval.push(chosenOne);
      }
    }
  });
}

return retval.join("|");

Assuming the HTML structure matches what's in your post, the above logic checks each checkbox to see if it is checked. If checked, it looks for the related <span> tag to get the name (eg// "Contemporary Arts"). This should work whether there's one option or 100. 

Answers (0)