This tutorial demonstrates a simple, code-less method for redirecting users back to the URL they came from before accessing the form. This is useful in situations where you may require registration or just to collect some information to view a page. After registration, you can easily redirect the user back to the page they were originally viewing.
Steps
1. Capture the Referrer URL
- Add a hidden field to your Gravity Form.
- Add {referer} to the Default Value for the hidden field.
- Save your form.
You may be wondering if Gravity Forms has a {referer}
merge tag, why don’t we just use that in the confirmation redirect?
The issue is that if you submit the form, the page URL that the form is submitted from becomes the referrer. We must stash the original referrer to the field.
2. Setup a “Redirect” Confirmation for Your Form
- Go the Confirmations page.
- Edit the default confirmation – or – add a new confirmation.
- Select “Redirect” as the “Confirmation Type”.
- Add the merge tag of the field we created in step #1.
- Save your confirmation.
All done!
How’d we do?
If you found this tutorial helpful, let us know. We’d love to hear any cool use-cases where you’ve put this technique into action!