0

I found this code online that has partially solved my issue.

<script>
  (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);
  })();
</script>

Is it possible to use the above mentioned script to detect all menu selections, opposed to only select#pa_vaelg-interval_19**.

Could I somehow express **select#pa_vaelg-interval(_1,_2,_3, ,a, b,)** etc?

Helio
  • 621
  • 1
  • 4
  • 24

0 Answers0