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 Trigger and Jquery Error.

  1. I am adding the following code to the function.php file to achieve Google Analytics Event Triggers. I believe the code is right.

    add_action("gform_after_submission", "gf_ga_tracking", 10, 2);
    function gf_ga_tracking($entry, $form) {
    ?>
    <script type="text/javascript">
     jQuery(document).ready(function($) {
     _gaq.push(['_trackEvent', 'Forms', 'Submission', '<?php echo $form["title"]; ?>']);
    });
    </script>
    <?php }

    but I am receiving a ReferenceError: jQuery is not defined @ http://domain.com/request-service/#gf_5:3

    I know I have to have jQuery added to the page. But I figured it was taken care of by another plugin from the following code on my page:

    <script type='text/javascript' src='http://domain.com/wp-content/plugins/wp-lightbox/js/jquery.min.js?ver=1.7.1'></script>

    Does it need to be a specific version?
    I disabled the plugin and I tried adding jquery by adding the following code into function.php:

    add_action('init', 'add_jquery');
    function add_jquery() {
    	wp_enqueue_script('jquery');
    }

    now it has the following code in the page source: <script type='text/javascript' src='http://domain.com/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>

    but still gives me the jquery not defined error.

    Thanks
    Greg

    Posted 10 years ago on Wednesday June 26, 2013 | Permalink
  2. Are you running a multi-page form by chance and are you using AJAX on the form embed?

    Posted 10 years ago on Friday June 28, 2013 | Permalink

This topic has been resolved and has been closed to new replies.