Button stops working when I'm adding a tracking event to the button

The button is linked to a lightbox, not through code, so super straight forward.
However, when I add a tracking event to it in the code, the link to the lightbox stops working.
Here’s the code I’m using:

export function button2_click(event) {
  wixWindow.trackEvent("CustomEvent", {
     "event": "Clicked Find me a Doctor",
     "eventCategory": "Button",
     "eventAction": "Click",
     "eventLabel": "Clicked Find me a Doctor"
   } );
 }

Any idea why is that happening? does the code overwrites the link?

Well think you have answered your own question as you can’t have the button linked through the editor and the button linked through code too.

The button either needs to be linked through to the lightbox in the editor without the tracking event in code, or you need to add the lightbox link and the tracking event both through code.