Google event tracking code, correct?
-
13-07-2021 - |
Question
I'm trying to track clicks on the submit-button on a form on a page but it's not working. I'm using this code:
$('#edit-company-questions-submit').submit(function() {
_gaq.push('_trackEvent', 'Forms', 'Submit', 'Sales contact');
});
Is this correct or have I misunderstood it?
Solution
You have to wrap your events in an array if you are using the default async snippet:
_gaq.push(['_trackEvent', 'Forms', 'Submit', 'Sales contact']);
Have a look at the Event Tracking Documentation for more examples. Also install the GADebug extension for Chrome to see what events get sent from your page.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow