Domain Manage

Google Analytics Event Tracking (Buttons)

Discussion in 'Website Design' started by wb, Mar 1, 2013.

Thread Status:
Not open for further replies.
  1. wb United Kingdom

    wb Well-Known Member

    Joined:
    Mar 2009
    Posts:
    2,072
    Likes Received:
    34
    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! :)
     
  2. Domain Forum

    Acorn Domains Elite Member

    Joined:
    1999
    Messages:
    Many
    Likes Received:
    Lots
     
  3. wb United Kingdom

    wb Well-Known Member

    Joined:
    Mar 2009
    Posts:
    2,072
    Likes Received:
    34
    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:
     
  4. martin-s United Kingdom

    martin-s Well-Known Member

    Joined:
    Jul 2012
    Posts:
    2,451
    Likes Received:
    83
    You don't need the "javascript:" inside an onclick event. You only need that inside an a:href link.
     
  5. wb United Kingdom

    wb Well-Known Member

    Joined:
    Mar 2009
    Posts:
    2,072
    Likes Received:
    34
    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.
     
  6. GotLiveChat

    GotLiveChat Member

    Joined:
    Jan 2011
    Posts:
    48
    Likes Received:
    0
    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.
     
Thread Status:
Not open for further replies.

Share This Page