How can Button open link in new tab *and* send tracking event?

A button has a link which can be set to open in a new window/tab. I also want to send a tracking event so I add an onClick() to do it, and that works but then the link no longer works. I’m sure there was a time when I could have both, but ok … there is documentation saying I shouldn’t have a link and an onclick handler so I won’t do that.

There is also documentation saying I can use wix-location.to() in the handler instead of the button’s regular link function. That does work, but it won’t open in a new tab, as noted in other discussions in this forum.

How can I open a button’s link in a new tab and also send a tracking event?

FYI I noticed wix-window.openModal(). That works but not the UX I want. I need something like javascript’s window.open() … is there a way I can call that from Corvid?

There are example pages that you can read about it here.
https://support.wix.com/en/article/corvid-tutorial-sending-tracking-and-analytics-events
https://support.wix.com/en/article/tracking-click-events-with-google-tag-manager

Also, if Wix Location API and the to() function is not suitable for you, then have a look at using target and link instead.
https://www.wix.com/corvid/reference/wix-location.html#to
https://www.wix.com/corvid/reference/$w.LinkableMixin.html

@GOS your second link might be useful, I have been thinking of using GTM and it looks like doing that would mean not needing a click handler, so I might just work around this problem. But meanwhile, I ought to be able to get this working with just GA Event posting, and solve this problem rather than doing something else entirely.

Your first link is just documentation about how to send tracking events, but I already have that working in isolation. Your last couple of links about LinkableMixins, I already looked at that. Several other threads in this forum conclude that it doesn’t work in onClick() handlers. So I’m not tempted to try it. Do you know that this would work in onClick() ?

Thank you