PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Google Analytics Event Tracking with Ajax Enabled

  1. This might be useful for someone else. I wanted to be able to track form submissions on Ajax-enabled Gravity forms with an analytics event, and I also didn't want to create separate confirmation pages for each form, or edit the confirmation message individually.

    Pastie for sticking in the active theme's functions.php:

    http://pastie.org/6361095

    The (ajax) confirmation message is in a frame which doesn't have access to jquery or the google analytics library, so the - perhaps a bit inelegant - solution is to call the scripts again from within that frame. Might also work just by pasting these into the confirmation message.

    Posted 11 years ago on Friday March 1, 2013 | Permalink
  2. It does normally work if you paste the code into the confirmation message area. You just have to be sure to check the "Disable Auto-formatting" box to ensure the JavaScript code is not altered.

    Thank you for sharing your solution.

    Posted 11 years ago on Monday March 4, 2013 | Permalink
  3. amadex
    Member

    It wouldn't be enough for the function to call only:
    <script type="text/javascript">
    jQuery(document).ready(function($) {
    _gaq.push(['_trackEvent', 'event_category', 'event_action', '<?php echo $form["title"]; ?>']);
    console.log('<?php echo $form["title"]; ?>');
    });
    </script>
    ?

    If it works from the confirmation message, why it wouldn't work from the function?

    Posted 11 years ago on Friday April 12, 2013 | Permalink
  4. Chris Rufo
    Member

    Hello,

    I'd like to follow up on this question. I'm searching for a simple way to get Google Analytics tracking and I'd love to not have to edit the core functions -- I'm new at this and really would love to see a simple Event tracking integrated into the Gravity Forms plugin.

    Anyway, does the suggestion above from amadex work? Can we simply paste that code into the confirmation message and it will start tracking? Anything else we need to do?

    Thank you!

    Christopher

    Posted 11 years ago on Wednesday April 17, 2013 | Permalink
  5. Sounds like quite a few request to apply event tracking. I'm looking for a solution to apply event tracking around next/submit buttons. I have a 2 step form before reaching the thank you page and would like to see the number of visitors that click on 'next' and 'submit application' and to compare against the number of actual conversions.

    Is there such a solution?

    Thank you!

    Posted 11 years ago on Friday April 19, 2013 | Permalink