So there are a few simple steps that I can help you with.
You will need a field to put in the referrer URL so that it gets saved to the entries table in Gravity Forms.
- Create a Hidden Field in your Form. (Hidden FIelds are in the Standard Fields set)
- Give it a label (Ref URL) - The label isn't important but helpful
- Under the Advanced Tab, click the check box for Allow Field to be Populated Dynamically
- Give it a Parameter Name (refurl)
You will need to create a function to grab the referrer URL and pass it to the hidden field.
#1 - In your theme's function.php file you will need to create a filter using the gform_field_value_$parameter_name hook: http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name
It will look like the following:
As you can see, I used the parameter name that I put in above (refurl).
#2 - Next we will need to code the referral_url function to grab the URL and then put it into the hidden field.
//Grab URL from HTTP Server Var and put it into a variable
$refurl = $_SERVER['HTTP_REFERER'];
//Return that value to the form
Now, if everything has been done correctly, when the form is loaded, the function will be called to grab the referral page and put the value into a hidden field. Then when you look at your entries, you should see which page lead them to your form.
Posted 10 years ago on Wednesday May 16, 2012 | Permalink