How to log button click redirect to website?

How do u log somebody clicking on a button then getting redirected to a another website?


(NOTE: i have no idea why the image is like that, but if its normal to you, then its prob for me only.)

To log something you will need some space where you can save your logs right?

This for i would suggest you to generate a DATABASE.
Add a DB-Field → called how ever you want to this DB, for example → “logs”

Now you write the code for your “button1”, which will activate the function.

import wixLocation from 'wix-location';

$w.onReady(()=>{
	$w('#button1').onClick(()=>{
	let URL = "https://www.google.com";
		wixLocation.to(URL);
		saveLog(URL)
	});
});

function saveLog(URL) {
	toSave = {
		title: "whatever",
		logs: URL
	}
	
	wixData.save("yourCollectionIDhere", toSave)
    .then((results)=> {
        console.log(results.items); //see item below
    })
    .catch((err)=> {console.log(err);});
}