2.1K 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

Event as a goal

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭


I wish to use 'Event' as a Goal in GA. There is  a 'contact us' form that we have on the website.Want to set the submission of the form as an event. I understand that there is an Event tracking code generator. Here, my question is what is the difference in the code that starts with on_sent_ok and the one that begins with onclick for Contact form.



1 Expert replyverified_user
Marked as Best Answer.
Accepted by topic author Rakhee G
June 2016

Re: Event as a goal

Top Contributor
# 2
Top Contributor



on_sent_ok is a JavaScript action hook in the Contact Form 7 Wordpress plugin. The hook is called upon a successful form submission. You need to add the event tracking code to the Additional Settings tab in the form editor screen like this:

on_sent_ok: "ga('send', 'event', 'Contact Form', 'submit');"

onclick is a JavaScript event that occurs when a user clicks on an element. Using the onclick event you can track a click on a submit button like this:

<input type="submit" onclick="ga('send', 'event', 'Contact Form', 'submit');">


So the second option would track all clicks on the submit button, not only successful form submissions. Let me know if you have more questions.

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