mardi 28 février 2017

Counting New Button Checks Using jQuery

Trying pass the number of newly checked, check boxes through Google Tag Manager:

function () { 
  var newChecks = 0;
  var counter = $('.checkBoxClass').change(function() 
  {
    if (this.checked) 
    {
      newChecks++;
    };
  })
  return newChecks;
}

When adding an alert to the this.checked function, it works well.
The only issue is that I am not seeing it pass through and save as a variable:

data not passing to variable

At this point I was also trying to run the .length of all checked boxes and by using .one run another parallel .length to capture the initial checkbox load for an equation of:

totalCheckBoxes - loadedCheckBoxes = total;
return total;

Feel like at this point there is something going on with GTM that I cannot see that's not saving the value.




Aucun commentaire:

Enregistrer un commentaire