menuselect detection for combobox and checkbox in gtm

Viewed 12

I have the following html tag to detect changes to menu selects.

(function() {
    
    // Change the CSS selector in the parenthesis to match your select menu
    var selectMenu = document.querySelector('select#pa_vaelg-interval_19');
    
    var callback = function(e) {
      var selectedOption = e.target.options[e.target.selectedIndex];
      window.dataLayer.push({
        event: 'selectionMade',
        selectedElement: selectedOption
      });
    };
    
    selectMenu.addEventListener('change', callback, true);
  })();

Is there a way to apply the same type of script for a "combo box" and a and an input "checkbox"?

0 Answers
Related