lundi 7 mai 2018

How to Datalayer.push a checkbox variable

i was hoping if somebody could help me figure out how to get datalayer.push data from checkboxes the user has selected on a form during submission. The form has many fields but i only want the checkboxes that have been selected.

This is what the form looks like ( it has 4 checkboxes like that)

<div class="form-choice-group ">
  <div class="form-check form-check--text-normal ">
    <input data-validetta="minChecked[1]" data-vd-parent-up="2" data-vd-message-minChecked="Vali vähemalt 1 teenus" type="checkbox" id="check-grey-0" class="form-check__input" name="teenused[]" value="IT (ITH, Office 365, seadmemajutus, IoT jne)">
    <label for="check-grey-0" class="form-check__label ">
                                <span class="form-check__indicator">
                                    <svg class="icon form-check__icon">
                                        <use xlink:href="/tk-telia-theme/images/icons.svg#check"></use>
                                    </svg>
                                </span>
                                <span class="form-check__text ">
        IT (ITH, Office 365, seadmemajutus, IoT jne)
                                </span>

                            </label>
  </div>
</div>

This is what my datalayer looks like

dataLayer.push({
        'event' : 'GAEvent',
        'eventCategory' : 'Uue Äri/IT kliendi müügivõistlus',
        'eventAction' : 'Saada müügivõimalus',
        'eventLabel' : $('.form-check__input').val()
    });

But it is not submitting the variables correctly and the datalayer says that the eventLabel is undefined. So im guessing this is wrong $('.form-check__input').val() Im really struggeling with this and some help would be greatly apreciated.

Thanks! Frank




Aucun commentaire:

Enregistrer un commentaire