(function (Drupal) {

  Drupal.behaviors.webformCustomBehavior = {
    attach: function (context) {
      // Ensure the code only runs once for each context
      if (context.webformCustomBehaviorAttached) {
        return;
      }
      context.webformCustomBehaviorAttached = true;

      // Find the submit button within the webform submission form
      var submitButton = context.querySelector('.newsletterpopupdownload #edit-actions-submit');

      if (submitButton) {
        // Add click event listener to the submit button
        submitButton.addEventListener('click', function (event) {
          _paq.push(['trackEvent', 'Newsletterabo', 'Download Popup']);
        });
      }
    }
  }

})(Drupal);