Analytics
2.3K members online now
2.3K members online now
Learn how to set up goals and Ecommerce tracking, verify accuracy of attribution traffic sources, and discuss funnel visualization, Multi-Channel Funnels, the Goal Flow Report, and Enhanced Ecommerce
 
Guide Me
star_border
Reply

Event Tracking onSubmit Code

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I'm trying to set up event tracking, but it doesn't work. The event counts zero on Google Analytics. I think there is something wrong with my code. Any ideas on what is wrong? Thank you.

 <input id="submit_o2830002"         name="/atg/commerce/order/purchase/CartModifierFormHandler.checkout" value="goCheckOut" class="endbtn" type="submit" onsubmit="ga('send', {
                        &nbsp; hitType: 'event',
                        &nbsp; eventCategory: 'Order',
                        &nbsp; eventAction: 'goCheckOut',
                        &nbsp; eventLabel: 'click goCheckOut'
                        });">
1 Expert replyverified_user
Marked as Best Answer.
Solution
Accepted by topic author Tiantaili P
July 2016

Re: Event Tracking onSubmit Code

Top Contributor
# 2
Top Contributor

Hi,

 

You need to add the onsubmit event to your form tag, not to the submit button, like this:

 

<form action="#" onsubmit="ga('send', {
                        hitType: 'event',
                        eventCategory: 'Order',
                        eventAction: 'goCheckOut',
                        eventLabel: 'click goCheckOut'
                        });">
<input id="submit_o2830002" name="/atg/commerce/order/purchase/CartModifierFormHandler.checkout" value="goCheckOut" class="endbtn" type="submit">
</form>

Hope this helps.


Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Event Tracking onSubmit Code

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
That does help!!! Thank you so much!! I can track my event now!