{solved} Button: Tracking & Downloading works not together

If you have a download button and would like to track the downloads, there is a beautiful wix guide how to do it

Unfortunately the download button stops working , because you are overriding the default href behavior with on_click event. And there is only the tracking code for google analytics.

If you would like to download the file too, you have to use
wixLocation.to( https://your-link-to-file );
after your tracking code. This is not shown in the video!

Unfortunately this link opens in the same window, because wixLocation.to() does not accept any specification where to open the link.

Wix does not allow to use the native javascript function window. open ( https://your-link-to-file ) which opens the URL by default in a new window.

So dear WIX Team, can you provide us with a better solution, so our links can open properly in a new window?

Best regards,
Miroslav

I have found a simple and cute workaround:

Don’t use Button. Instead use a picture of the same button e.g. as a vector graphic in SVG. Then link it to a document and add onclick event only with the tracking code. It works like a charm. Enjoy :heart_eyes: