Tagged: event, google analytics, onclick
Hi there,
We’re trying to get some events set up in Google Analytics to track clicks. The code involves adding the following onclick= within the <a href string:
The clicks we would like to track are buttons within the main nav and also buttons on the homepage and elsewhere within the site. How can we add this onclick= code when we’re using Enfold buttons and main nav links?
Hey jaimemerz,
Thank you for the inquiry.
You can attach a click event listener to the menu items and execute the Google Analytics function or tracker when someone click on the element. If you’re using jQuery, the script might look something like this.
$(".menu-item').click(function(){
// GA tracker here
});
Best regards,
Ismael