Add referer URL to Contact Form 7 Form and Email.

For those of you supporting WordPress sites with Contact Form 7, this is a quick customization you can do to make sure that your form submissions provide a little extra information about where the user was previously before accessing your form. Here is the URL of the original post by aravindajith. Unfortunately the original site that was referenced is no longer live, but many thanks to Tony Kwon as well.

  1. In your Contact Form 7 form, add a Text Field element with a css class referer-page. That will look something like this:
    [text referer-page class:referer-page]
  2. Add the following css to your styles.css
    input.referer-page { display:none; }
  3. Add the following code snippets to your functions.php?
    function getRefererPage( $form_tag )
    if ( $form_tag['name'] == 'referer-page' ) {
    $form_tag['values'][] = htmlspecialchars($_SERVER['HTTP_REFERER']);
    return $form_tag;
    if ( !is_admin() ) {
    add_filter( 'wpcf7_form_tag', 'getRefererPage' );
  4. Add the following to the Contact Form 7 Message body (under Mail)
    Referer Page: [referer-page]