Google Analytics Event Tracking

Hello,

Our website has a button that you click that takes you to a new page to fill out a form. We’re trying to create an event so we can track anyone who starts to fill out the form. I need to either track the button click or the pageview as an event. I’ve tried putting the code below in, it tracks the event but it no longer links to the screener page:

import wixWindow from ‘wix-window’;
export function screener_click(event) {
wixWindow.trackEvent(“CustomEvent”, {
“event”: “screener_click”,
“eventCategory”: “screener”,
“eventAction”: “click”,
} );
}

Any help would be greatly appreciated :slight_smile:

Thank you

Hi,

If you want to fire an event and redirect to another page at the same time do this:

import wixWindow from 'wix-window';
import wixLocation from 'wix-location';
 
export function screener_click(event) {
 wixWindow.trackEvent("CustomEvent", {
   "event": "screener_click",
   "eventCategory": "screener",
   "eventAction": "click",
 })
 .then( () => {
   wixLocation.to('/your-page-here');
 });
}

Remember to disconnect the link from the dataset first.

Read more about wix-location API here: wix-location-frontend - Velo API Reference - Wix.com