title: How do I get the current page in Gravity Forms
body: <p>How do I get the current page of a multi page form in Gravity Forms? I've got two solutions that sort of work but neither fully work.</p>
  
  <pre><code>function gf_get_current_page() {
      return rgpost( 'gform_source_page_number_' . $_POST['gform_submit'] ) ? rgpost( 'gform_target_page_number_' . $_POST['gform_submit'] ) : 1;
  }
  </code></pre>
  
  <p>This solution works until someone doesn't fill out a required field before hitting the next button. Then it says the user is on page 3 even though they're still on page 2 and need to fix validation errors.</p>
  
  <pre><code>add_action( 'gform_post_paging', 'get_current_page_num_gf', 10, 3 );
  function get_current_page_num_gf( $form, $source_page_number, $current_page_number ) {
          echo '&lt;script type="text/javascript"&gt;console.log(\'' . $current_page_number . '\');&lt;/script&gt;';
  }
  </code></pre>
  
  <p>This works well until the validation errors again. In this scenario, instead of changing the page number, it just outputs nothing.</p>
  
  <p>I'd like to know what page the user is on at all times. If they miss a required question on step 2, then I'd like to know that they're still on step 2.</p>
  
  <p>In the end, I'm hoping to send all this information back to Google Analytics and getting accurate information as to what step the user is on is not working well.</p>