I’m a complete novice to coding but have made an attempt to record button clicks as an event on Google Analytics, but it doesn’t seem to be working. Code is below if anyone can shed any light id appreciate it!
import wixWindow from ‘wix-window’;
export function button2_click(event) {
wixWindow.trackEvent(“CustomEvent”, {
event: “Button Click”,
eventCategory: “Homepage”,
eventAction: “Button Click”,
eventLabel: “Satisfaction Survey”
} );
}
export function button1_click(event) {
wixWindow.trackEvent(“CustomEvent”, {
event: “Button Click”,
eventCategory: “Homepage”,
eventAction: “Button Click”,
eventLabel: “Adult Complaints Guide”
} );
}
export function button7_click(event) {
wixWindow.trackEvent(“CustomEvent”, {
event: “Button Click”,
eventCategory: “Homepage”,
eventAction: “Button Click”,
eventLabel: “Young Person Complaints Guide”
} );
}
Thanks!
Looks like you have read this page.
https://support.wix.com/en/article/corvid-tutorial-sending-tracking-and-analytics-events
Have you done this first?
We begin by connecting the desired tracking and analytics tools to our site. Currently, you can send events through code to Google Analytics and Facebook Pixel. To learn how to connect tracking and analytics tools to your site, see About Tracking Tools & Analytics .
Also, note that you need to have a premium account with Wix and you need to have published your site for it to work.
Also, make sure that you have added the onClick event handler through the properties panel too and not just typed up that code for the export function.
https://support.wix.com/en/article/corvid-working-with-the-properties-panel
Wix already had a tutorial about setting this up.
See the video here and look at the code reference page too.
How to Use Wix Code with Marketing Tools to Create Custom Events
https://www.wix.com/corvid/reference/wix-window.trackingParameters.html#CustomEvent
Plus, you might be better off using Google Tag Manager too, however that choice is yours.
https://support.wix.com/en/article/tracking-click-events-with-google-tag-manager
Wix Tutorial - Click Event Tracking with Google Tag Manager
Finally, you probably already have, however see these links for more info.
https://support.wix.com/en/marketing-tools-analytics/marketing-integrations-tracking
https://support.wix.com/en/marketing-tools-analytics/google-analytics
Hi GOS,
I just set up the tracking on my website. The events fire correctly to GA, but the button doesn’t work anymore when I add the onClick event on the button.
Here is the code used on the button.
export function navHomme_click(event) {
wixWindow.trackEvent("CustomEvent", {
"event": "nav-boutique",
"eventCategory": "Nav Boutique - Click",
"eventAction": "Gamme",
"eventLabel": "Hommes",
} );
}
Any idea why the button does not work anymore (nothing happens when I click on it, but the link is set properly)?
Thanks
Vincent
When you say that you have the link set correctly, can we assume that you have added the link through the link settings in the Wix Editor itself?
Plus you have also added code to it so that it does something in the onClick event handler function, in this case the track event.
If you have done both, then it won’t work as you can’t have two different actions in the same thing.
If you want the user to go somewhere when they click on it and also send your track event, then it must all be written into the code used above.
You need to add a Wix Location import at the top of your code and use the to() function from it at the end of your existing code after the label line to move the user onto another page.
https://www.wix.com/corvid/reference/wix-location.html#to
You can add code to your page that does all the buttons as shown here.
https://www.wix.com/corvid/forum/community-discussion/multiple-button-one-function
Finally, please add a new post rather than bumping up an old thread from last year.