Reputation: 21150
I have a contact form whose id is #mailButton
. I've set up Google Analytics for the site (which works just fine). The site is much bigger than this (and runs on WordPress) but a truncated version is:
<form>
<input type="submit" class="button" id="mailButton">SUBMIT</input>
</form>
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']); // Edited out my account number
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<script>
$('#mailButton').click(function() {
console.log("Button Clicked!");
_gaq.push('_trackEvent', 'Contact', 'New Enquiry');
});
</script>
When I click the button, console correctly logs Button Clicked!
. However, Google Analytics shows no event when I go to Behaviour -> Events -> Overview
. I've clicked it many, many times, it only shows once click event from a few weeks ago (when I didn't click it but a customer might have). What am I missing here?
For further clarification, this contact form is being generated by Wordpress' "Contact Form 7", if that makes any difference here
Live site is here: http://agoodman.com.au/ and the contact form in question is the one right next to the video.
Upvotes: 0
Views: 408
Reputation: 446
You have made a small mistake, you have missed “[ ]“ . Correct it, Should work
New Code
_gaq.push(['_trackEvent', 'Contact', 'New Enquiry']);
Upvotes: 1