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.

Integrate clicktale with AJAX multipage form

  1. idealists
    Member

    Hi

    Can anybody shed some light on how best to integrate clicktale to gravityforms (ajax) multipage forms?

    Clicktale provides 2 javascript codes, one that should be placed after <body> tag:
    <body>
    <script type='text/javascript'>
    var WRInitTime=(new Date()).getTime();
    </script>

    The other before </body> tag:
    <!-- ClickTale Bottom part -->
    <div id="ClickTaleDiv" style="display: none;"></div>
    <script type="text/javascript">
    if(document.location.protocol!='https:')
    document.write(unescape("%3Cscript%20src='http://s.clicktale.net/WRb6.js'%20type='text/javascript'%3E%3C/script%3E"));
    </script>
    <script type="text/javascript">
    if(typeof ClickTale=='function') ClickTale(xxxx,1,"www07");
    </script>
    <!-- ClickTale end of Bottom part -->

    If I did it exactly like that I do not believe it world record pages beyond the 1st page in the multi-page form. (correct me if I am wrong).

    Any suggestions would be greatly appreciated. Thanks

    Posted 8 years ago on Friday February 11, 2011 | Permalink
  2. idealists
    Member

    I may have another way of doing it with PHP using:
    http://wiki.clicktale.com/Article/PHP_integration_module

    Only thing, in order to cache the form page I need to be able to trigger both:
    <?php
    require_once("[physical_path_to_clicktale_dir_here]\ClickTale\ClickTaleTop.php");
    ?>
    <?php
    require_once("[physical_path_to_clicktale_dir_here]\ClickTale\ClickTaleBottom.php");
    ?>

    Every time a new ajax form page is loaded. I know there is javascript hook for this:
    jQuery(document).bind('gform_page_loaded', function(event, form_id, current_page){

    But is there a PHP hook I could use to call the above PHP codes when the multi-page form page is changed? Need to do this to cache/capture the page.

    Posted 8 years ago on Friday February 11, 2011 | Permalink
  3. I'm not familiar with ClickTale or what it does. Depending on how it works it should record multiple pages beyond the 1st page. You should test it out using it with AJAX turned on and AJAX turned off. If it doesn't work with AJAX multi-page it may work with it turned off.

    Posted 8 years ago on Friday February 11, 2011 | Permalink
  4. idealists
    Member

    Question, does gform_page_loaded work with AJAX off?
    If not, is there a similar jquery hook that will return the page number/"current_page" on multipage forms with ajax turned off?

    Or even for that matter a PHP hook that returms the current page of the multi-page form?

    Posted 8 years ago on Saturday February 12, 2011 | Permalink
  5. I've forwarded your question to another member of our team who is more familiar with the gform_page_loaded hook. He will reply to this thread once he has a chance... it may take sometime as it's currently after business hours and a weekend.

    Posted 8 years ago on Saturday February 12, 2011 | Permalink
  6. The gform_page_loaded is a Javascript hook and only applies to AJAX forms. For non AJAX forms, you could use the gform_pre_render hook to get access to the current page number. See below.

    add_filter("gform_pre_render", "gf_pre_render");
    function gf_pre_render($form){
        $current_page = 1;
        if(isset(GFFormDisplay::$submission[$form["id"]]))
            $current_page = GFFormDisplay::$submission[$form["id"]]["page_number"];
    
        echo "page: {$current_page}";
    
        return $form;
    }
    Posted 8 years ago on Saturday February 12, 2011 | Permalink
  7. idealists
    Member

    Thank you for that.

    Is there also another hook, that occurs at the end of the output, like gf_post_render?

    Also, do these hooks work when using AJAX forms?

    Posted 8 years ago on Monday February 14, 2011 | Permalink
  8. No, we don't have a "Post Render" hook. I haven't found a case where that would be helpful yet. But yes, the PHP hooks (i.e. gform_pre_render) will fire on AJAX forms.

    Posted 8 years ago on Monday February 14, 2011 | Permalink