Installed latest version with WordPress 3.5.2, working ok.
How can I add onsubmit=”_gaq.push([‘_trackEvent’, ‘SomeCategory’, ‘SomeAction’, ‘Some label’]);” to the form? Can’t find it in the config.
I do not use GA so I have not had to do this.
Where in the form do you need to add the onsubmit?
I searched google site and cannot find the answers.
If anybody can help, that would be great
Hi Mike, thanks for replying.
Crash course into Analytics: using a .js from their servers they track usage of the site ( source of visit, pages viewed, time on site etc ). That’s default after installing their script.
So _gaq.push() – a bit about the benefits: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
TL;DR version: When then user does something, especially click a link or submit a form, Google Analytics will track this.
Of course, clicking a link can be tracked with referral, so why does this count for anything?
We all have some actions in the site that have greater value to us. For some it may be playing a video or submitting a form.
In my case, it’s the form.
So, you have
<form action="php stuff">some html stuff</form>. This basic form will get your info somewhere. But if you want to track the source of the action ( like the landing page, previous page, visit source ) you’ll need to add aditional info.
You do that by placing
onsubmit="_gaq.push(['_trackEvent', 'Contact', 'SubmitForm', 'Contacts']);"before closing the <form tag
So, while having
<form action="http://mywebsite.com/contact#FSContact1" id="si_contact_form5" method="post">you add the previously mentioned code to track it in Google Analytics.
My desired example code would be:
<form action="http://mywebsite.com/contact#FSContact1" id="si_contact_form5" onsubmit="_gaq.push(['_trackEvent', 'Contact', 'SubmitForm', 'Contacts']);" method="post">
Another option would be adding this with
onclick=""on the Submit button, but that would get some false positives since not all clicks get past validation.
If you decide to get this into the plugin I can help with the testing.
Nice plugin BTW, works great for my dev, will rate it after it’s live.
Hope I made it clearer now.
Thanks for the explanation, I will add a way to do that. Maybe this weekend. If you contact me, I will let you test it first.
The next version will have these new settings: “Submit button input attributes” and “Form action attributes”.
(18 Jul 2013) – added new settings: “Submit button input attributes” and “Form action attributes”. These can be used for Google Analytics tracking code.
added captcha font randomization.
fixed date does not have to be required.
fixed date error message translation.
Great plugin, thanks a lot.
I have also been using the new onsubmit function, but I noticed one thing: apparently the “form action atrributes” only work for a form’s first email. Let me explain: We have a contact form with a drop-down that is setup so that if they select “Berlin” the email will go to berlin@… and if they select “Hamburg” it will go to hamburg@… So far so good. Now I tried to use the onsubmit to track the number and source/keywords/etc. for each form submission, but Google only seems to be tracking submission for the first address listed (in this case Berlin). I know other submissions are being made since the emails are coming through, but Hamburg’s stats are just not showing up on Google.
Is this a limitation of the plug-in or maybe just a bug?
Any info would be greatly appreciated.
Here’s a link to our site in case you want to see the form in action 😉
Edit: After doing some more searching, it seems that all the events are properly registering under Content-Events, but are not registering as a created goal. I’m gonna look into this further, but I don’t think this is a problem with your plugin. Thanks again!
I am trying to work on some technical things for our SEO firm. They need me to insert a code that track the source of Google AdWords (natural search, organic search, etc.).
I see in the back-end of Fast Secure Contact Form there are two fields under Advanced: (1)Submit button input attributes & (2)Form action attributes. When I click help, it displays an example code (e.g., onSubmit=”pageTracker._trackEvent(‘Contact Form’,’Submit’);” & onsubmit=”_gaq.push([‘_trackEvent’, ‘Contact’, ‘SubmitForm’, ‘Contacts’]);”).
Is this all that needs to go in these spaces in order to get this to work? Is there additional code that I need to put in? Do I need to put the specific name of the contact form instead of “Contact Form” or “Contact”?
- The topic ‘Adding onsubmit for Google Analytics’ is closed to new replies.