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.

Redirect Form to Page causing multiple Page Views?

  1. Hi.

    Right Around the May 1, 2012 update, I noticed that I am getting a large amount of page views for my form redirect pages. For example, I have a form: let's call it contact-us. this form redirects to a page: contact-us-thank-you. Starting May 3rd (the day after I updated to the latest gravity forms version), page views for my contact-us-thank-you have gone through the rough. Where uniques have stated the same.

    I noticed that this error is heavily related to Internet Explorer users. Specifically IE7 & IE8, but IE9 does have some issues. I'm wondering if somehow the redirect to a page is getting caught in a loop where it keeps redirecting even though its finished.

    Posted 11 years ago on Tuesday May 22, 2012 | Permalink
  2. David Peralty

    Once you get to your thank you page, I'm assuming there is no Gravity Forms code on that page, and so once Gravity Forms pushes a user there... it is done. It can't create any kind of a redirect loop. Maybe try checking for JavaScript issues on your thank-you page, or any code that would create redirect loops outside of Gravity Forms.

    Posted 11 years ago on Tuesday May 22, 2012 | Permalink
  3. Thanks David.

    I will look, for some JavaScript issues- but this is happening on multiple different forms for me.
    The thank you page is really plain vanilla.

    Here is an example of one of my forms:
    http://www.screenflex.com/ customer-service/contact-us/
    This Form above redirects to this page:
    http://www.screenflex.com/ customer-service/contact-us/thank-you/

    The thank-you page is deliberately not indexed in google. I redirect to a page, so I can have google analytics track conversions. The only way you'll get to the different thank you pages is if you complete the form.

    Its been working fine since Oct 2011, then all of a sudden in May 2012, I am having big pageview differences for my thank-you pages. My thank-you page view count might be 1000, but my unique page view count might be 200 Another thank-you page view count might be 50, but my unique page view count is 15. Before May, the page view count and the unique page count were very close in number.

    Its not something you would notice unless you were looking for it.

    "so once Gravity Forms pushes a user there... it is done." I agree, I was just wondering maybe it would happen in the Validation somehow. Maybe someone, validates incorrect, then gets redirected, I don't know. I'm just trying to identify why has changed and throwing out a hypothesis.

    I'll keep digging.

    Posted 11 years ago on Tuesday May 22, 2012 | Permalink
  4. David Peralty

    It shouldn't redirect to the thank you page until all of the data they've entered is correct.

    Posted 11 years ago on Tuesday May 22, 2012 | Permalink
  5. After looking at the dates, I realized I put this code into production: May 2, 2012 the same date that I updated to May 1, 2012 update.

    Could using the gform_valication_message filter or the gform_validation_
    be the cause?

    Code:

    add_filter("gform_validation_message", "ss_change_message", 10, 2);
    function ss_change_message($message, $form){
        switch($form['id']){
            case 5:
            case 4:
            case 3:
            case 1:
                return "<div class='error_message'>Please submit your choice of email address or phone number.  Thank you.</div>";
                break;
            default:
                return "<div class='error_message'>There was a problem with your submission. Errors have been highlighted below.</div>";
                break;
        }
    
    }
    
    //Require a Phone or Email address for the following forms
    add_filter('gform_validation_5', 'ss_validate_phone_or_email');
    add_filter('gform_validation_4', 'ss_validate_phone_or_email');
    add_filter('gform_validation_3', 'ss_validate_phone_or_email');
    add_filter('gform_validation_1', 'ss_validate_phone_or_email');   
    
    function ss_validate_phone_or_email($validation_result){
    
         //  - Get the current form
         $form = $validation_result["form"];
    
         //  - Get the current page being validated
         $current_page = rgpost('gform_source_page_number_' . $form['id']) ? rgpost('gform_source_page_number_' . $form['id']) : 1;
    
         //   - Initalize Count for the quantity of fields found
         $count = 0;
    
         //  - Loop through the form fields
         foreach($form['fields'] as &$field){
    
            //  - If the field does not have our designated CSS class, skip it  Logically, if we are NOT phone or NOT email, skip it.
            if((strpos($field['cssClass'], 'request-phone') === FALSE) && (strpos($field['cssClass'], 'request-email') === FALSE)) {
                continue;
            }
    
            //  - Get the field's page number
            $field_page = $field['pageNumber'];
    
            //  - Check if the field is hidden by Gravity Forms conditional logic
            $is_hidden = RGFormsModel::is_field_hidden($form, $field, array());
    
            //  - If the field is not on the current page OR if the field is hidden, skip it
            if($field_page != $current_page || $is_hidden)
                continue;      
    
            //  - Get the submitted value from the $_POST
            $field_value = rgpost("input_{$field['id']}");
    
            //  - If the field is not empty, skip it.
            if(empty($field_value)== false){
                continue;
            }
    
            //  - Set the validation result as invalid
            $is_valid = false;
    
            //  - The field failed validation, so first we'll need to fail the validation for the entire form
            $validation_result['is_valid'] = $is_valid;
    
            //  - Mark the specific field that failed and add a custom validation message
            $field['failed_validation'] = true;
            $field['validation_message'] = 'Either a Phone Number <strong>OR</strong> an Email Address is required.';
    
            //  - Increment our count
            $count++;
         }
    
         //  - If our count is less than two, then one of our fields was valid, and there is no need to mark the entire form invalid.
         if($count < 2){
            $validation_result['is_valid'] = true;
         }
    
         //  - Assign our modified $form object back to the validation result
         $validation_result['form'] = $form;
    
        //  - Return the validation result
        return $validation_result;
    
    }

    The one issue I wonder though: I have other forms that don't use this validation code and they are having the same inflated pageviews, and I'm not sure why.

    I have a lot of moving options here, and I'm trying to eliminate options.

    Another potential option: Could having a email notification set-up without an email required do this?
    Again, I have forms that have required email and they still have inflated page views.

    Thanks again for your help.

    Posted 11 years ago on Wednesday May 23, 2012 | Permalink
  6. David Peralty

    I wouldn't think it has anything to do with this as the validation hook is fired before the redirect. What is on your redirect page? Is there anything that could be attempting to push users back to the page they just came from or is there a redirect/reload on the page you are sending them to? Or is there any JS issues on the page you are sending them to?

    Posted 11 years ago on Wednesday May 23, 2012 | Permalink