title: Store first referring URL in one variable along with $_SERVER['HTTP_REFERER'] in another
body: <p>I'm using the two functions below to store referrer information in variables which are inserted into a form email body. I need to store the first referring site or URL in one variable and the normal referring URL in another. Basically I need to get the first page or search engine which has referred a visitor, then store the very last page on my site they visited before coming to the contact form. The second part works with the first function getting the HTTP_REFERRER. But my function (function getFirstPage) to get the original referrer is just sending the contact page URL to me in the variable.</p>
  
  <pre><code>function getRefererPage( $form_tag )
  {
          if ( $form_tag['name'] == 'referer-page' ) {
                  $form_tag['values'][] = $_SERVER['HTTP_REFERER'];
          }
          return $form_tag;
  }
  function getFirstPage( $form_tag )
  {
  session_start();
          if (!isset($_SESSION["origURL"]))
              $_SESSION["origURL"] = $_SERVER["HTTP_REFERER"];
  
          if ( $form_tag['name'] == 'first-page' ) {
              $form_tag['values'][] = $_SESSION["origURL"];
          }
          return $form_tag;
  }
  if ( !is_admin() ) {
          add_filter( 'wpcf7_form_tag', 'getRefererPage' );
  }
  if ( !is_admin() ) {
          add_filter( 'wpcf7_form_tag', 'getFirstPage' );
  }
  </code></pre>
  
  <p>What can I change to get the original referrer into my function getFirstPage?</p>