Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

Google Analytics Event Tracking (Buttons)

Status
Not open for further replies.

wb

Joined
Mar 1, 2009
Posts
2,061
Reaction score
56
I'm trying to use the Google Analytics Event Tracking feature to track the total number of forms submitted on a page, but can't seem to get every submission to track (previously only needed to use this feature for text/image links and it's always worked perfectly).

Tried placing the the following within the <form> tag:

Code:
onsubmit="javascript:_gaq.push(['_trackEvent', 'XXX', 'YYY']);"

Also tried the alternative option of placing the following within the <input> tag for the button:

Code:
onclick="javascript:_gaq.push(['_trackEvent', 'XXX', 'YYY']);"

Does anyone know where I could be going wrong here? Having searched for answers, others have had similar difficulties but haven't found a solution either.

Thanks! :)
 
After doing some further research, submissions aren't always being tracked as some users are forwarded to the next page before the tracking pixel has a chance to register.

The post below claims to solve that, and having tested it out the tracking does seem to work correctly when clicking the submit button but the form doesn't actually submit. :(

http://stackoverflow.com/a/12461558

Do we have any JavaScript experts here? :confused:
 
You don't need the "javascript:" inside an onclick event. You only need that inside an a:href link.
 
Thanks, wasn't sure if it was needed or not so I'd left it in originally. Didn't seem to make any difference either way, so will get rid. :)

To update my previous post, I've tried using onmousedown instead of onclick this afternoon and it seems to have resulted in much better accuracy (presumably as onmousedown gives the tracking pixel a slight head start on the form submission).

This still isn't ideal though, as submissions are going to be tracked even if the user doesn't release the mouse (i.e. doesn't result in a click). Any assistance or ideas appreciated.
 
When exactly is the tracking pixel being pulled down? You may be able to do a form submit using javascript, except possibly try to pause the form processing.
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

Premium Members

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom