bookmark_borderCapturing The HTTP Referrer URL On Form Submissions

If you’re trying to determine what page caused a form submission to occur, and need to get the referrer URL, here’s how to do it.


  1. Create a hidden field on your form.
  2. Add a label to it such as Referrer URL so that you’re able to keep track of it a bit easier.
  3. Allow the field to be populated dynamically by accessing the advanced tab and enabling the checkbox.
  4. Give it a parameter name. In this example, we’ll use refurl.


After you have the initial setup completed, you’ll be able to use the following snippet to dynamically populate the field with the HTTP referrer URL.

add_filter( 'gform_field_value_refurl', 'populate_referral_url');

function populate_referral_url( $form ){
	// Grab URL from HTTP Server Var and put it into a variable
	$refurl = $_SERVER['HTTP_REFERER'];

	// Return that value to the form
	return esc_url_raw($refurl);

After that, the hidden field will then be dynamically populated with the HTTP referrer URL. Upon submission, the details will be sent with the submission.