Here's an easy way to set up Google Analytics event tracking for a successful Gravity Forms form submission: http://pastie.org/1057774
Paste this code into your theme's function file. This code assumes that you have already included jQuery and the Google Analytics embed code for your site.
Quick break down:
edited December 19, 2013 to change from gform_post_submission to gform_after_submission.
add_action("gform_after_submission", "gf_ga_tracking", 10, 2);
We make use of the gform_after_submission action to trigger a function after the form has been submitted. The entry is validated before this action is called, so we know that the form has been submitted successfully.
if($form['id'] != 4) return;
We check to make sure that we only continue processing this function if we are on the correct form. Replace '4' with your form id.
_gaq.push(['_trackEvent', 'Forms', 'Submission', 'GA Testing Form FINAL']);
This next bit assumes that you already have the Google Analytics embed code on your site and jQuery included. All we're doing is "pushing" an event to GA. For more information on this line, check out the GA documentation.
And that, my friends... is all there is to it. I'll do a more thorough write up as time allows. Hope this helps! :)
Posted 6 years ago on Friday July 23, 2010 | Permalink