Redirect to Referrer URL after Gravity Form Submission

Capture the URL from which the user just arrived then redirect them back to that URL on form submission.

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.

This is especially useful if you’re using Gravity Forms to register a user via the User Registration add-on. The user attempts to access a protected page. They are directed to a separate page to register (via a Gravity Form). The registration form redirects them back to the now-unlocked page.

To streamline the process even further use the GP Auto Login plugin so the user arrives at the previous page already logged in and ready to view the protected content.


  1. Capture the Referrer URL
  2. Setup a “Redirect” Confirmation for Your Form

1. Capture the Referrer URL

  1. Add a hidden field to your Gravity Form.
  2. Add {referer} to the Default Value for the hidden field.
  3. 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

  1. Go the Confirmations page.
  2. Edit the default confirmation – or – add a new confirmation.
  3. Select “Redirect” as the “Confirmation Type”.
  4. Add the merge tag of the field we created in step #1.
  5. 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!


  1. Arsalan
    Arsalan February 7, 2023 at 12:56 pm

    I am not able to redirect new page after form submission. I am getting only success message as a array format. Kindly let me know solution please.

    1. David Smith
      David Smith Staff March 6, 2023 at 9:00 pm

      Hi Arsalan, I confirmed this is still working with the demo so if you’ve configured it the same way, it should work for you too. If you’re a Gravity Perks customer (with an Advanced or Pro license), we’ll be happy to explore your configuration directly and see what might be going on. Drop us a line via support.

  2. Angelo
    Angelo December 21, 2022 at 5:11 am

    Hello, Does the redirect work when I click the activation link?

    Moreover Is the page that returns the registration confirmation closed when the user redirected to the page of origin is activated?

    Thank you!

  3. Scot MacDonald
    Scot MacDonald October 12, 2021 at 10:15 pm

    This is a nice solution. Is there a way it could work with a slight delay, in other words a short confirmation message and then redirect to the referer url?

    1. Samuel Bassah
      Samuel Bassah Staff October 13, 2021 at 6:17 am

      Hi Scott,

      This is currently not possible. It may require some custom coding. I’ll forward this to our developers as a feature request. We’ll reply to you via email if we do come up with a snippet for this.


  4. Raquel
    Raquel December 4, 2020 at 5:34 am

    Hi! I’ve a question about the gravity forms integration with Google Tag Manager… I’m trying to track the form with google tag manager but the “listener” is only activated when AJAX is activated … If the confirmation of the form redirects to another page, the “listener” is not working … Please can you help me with this issue? thank you in advance!

  5. Dan
    Dan September 17, 2020 at 7:20 am

    I really love this solution but …. I would like to put forms in a lightbox, then have the redirect go to the “parent” page. There appears to be no way to add that attribute to a redirect. Any ideas?

    1. Samuel Bassah
      Samuel Bassah Staff September 17, 2020 at 9:02 am

      Hi Dan,

      I’d think setting the confirmation type for the forms in the lightbox directly to the Parent Page using the Page property instead of Redirect should work for you.


  6. Amy
    Amy July 28, 2020 at 9:02 pm


    Is {referer} merge tag only used for successful form submissions?

    I’m using a woocommerce + gravity form add on to create a product which then I place on a marketing page using a shortcode.

    When there is an error in the gravity form submission (i.e. empty required field) it redirects to the actual product page instead of the marketing page.

    Is there a way to have the gravity form redirect back to the marketing page when there are errors in the submission?

    I’d appreciate any guidance with this. Thx!

    1. Ryan Donovan
      Ryan Donovan July 29, 2020 at 11:29 am

      Hello Amy, generally the {referer} tag will be activating after a successful submission. When you state errors in the submission, are you trying to navigate back to the validation error or are you trying to redirect the user to a completely different page when an error is present? Let us know you intent so we can possibly find a solution for you. 😃

    2. Amy
      Amy July 29, 2020 at 10:39 pm

      Thank you for your response Ryan.

      Gotcha, so {referer} tag is only for successful submission. That’s what I thought.

      I am using Gravity Forms Product Add-ons ( to add a Gravity Form to a woocommerce product.

      The form asks for an invitation email + code pair in order to be able to proceed in purchasing the woocommerce product.

      Woocommerce makes a default product page, which works perfectly. But, my team wants to design an entirely separate “Sales Page” to sell the product and make it look really enticing versus making changes to the default product page.

      I am using woocommerce’s builtin shortcodes ( to add this product to a separate page.

      It works as expected if the submission is successful. But, when there are errors in the submission instead of refreshing and staying on the “Sales Page” it redirects and goes to the default product page. Validation error messages show but it’s the wrong page. I would expect it to stay on the “Sales Page”.

      Thank you for any suggestions on how to fix this.

    3. Ryan Donovan
      Ryan Donovan July 30, 2020 at 9:55 am

      Hey Amy, I see! It is referring back to product page but not the sales page. This one is kind of hard to decipher without seeing the actual form. Sending a different redirect would be a little tricky but we would have to make sure this was needed first. If you have a Gravity Perks license, we could take a deeper dive into your forms via our support channel found here. 😃

  7. JR
    JR December 23, 2019 at 8:18 am

    Any reason why the {referer} merge tag wouldn’t be working? Your instructions work perfectly, but the referer field always ends up blank. I have tried using other merge tags and they work perfectly… though not for this application.


    1. David Smith
      David Smith Staff January 7, 2020 at 3:25 pm

      Hm, the fact that is always empty seems strange. The HTTP referer header from which the {referer} merge tag retrieves its value is optional but it typically present. Not sure why it is always empty in your tests…

  8. Alvaro
    Alvaro January 25, 2019 at 6:18 am

    Hello David,

    i bought the GP Auto Login plugin and it´s working fine. I made two forms. The first one is the login with all its credentials. A second form gets all the parameters from the first form to fill hidden fields and to submit an appointment. If i disable the user activation it works as it should.

    And here´s my challenge:

    When i enable the user activation, the confimation site should be the second form with all the parameters from the first form and not the standard “you are logged in” confirmation site. Is that possible or am i trying something that it´s not possible?

    Looking forwared to your response.

    Best regards,


    1. David Smith
      David Smith Staff January 30, 2019 at 3:50 am

      It sounds like you want to redirect the user to a different URL after they’ve clicked the activation link in the activation email? If so, you might consider our Better User Activation perk. It will let you specify a URL. The tricky part will be appending the entry data from Form A into that redirect URL… I’d be happy to dig in and see if this is possible via support. Drop us a line.

  9. Prince
    Prince October 31, 2018 at 1:11 pm

    Hi David,

    I need to add a “#” at the end of the redirection url, but it is removing “#” while redirecting. What can I do? Thanks in advance.

  10. Chetak
    Chetak May 6, 2018 at 12:26 pm

    Hi, can you help me with redirecting the newly created blog post with gravity form. As all posts have unique url created by gravity form, the moment author hit post button, I want it to be redirected to that new created post page automatically. Kindly help. Chetak

  11. Dave Mackey
    Dave Mackey August 12, 2017 at 6:52 am

    When I use this method it returns me to the referrer url but it strips off the query string. Any suggestions? I checked Yoast and it is configured not to strip the query strings.


    1. David Smith
      David Smith Staff August 17, 2017 at 11:24 am

      Hi Dave, I tested this locally but was unable to recreate the same issue. The query string was preserved. Possibly a theme/plugin conflict?

  12. maro
    maro August 16, 2015 at 7:43 am

    hi i want send data in url parametre from wordpress to anthother site. i have “form gravity” . i cant used this to send data in anothor website?!

  13. Michael Horwitz
    Michael Horwitz July 15, 2015 at 2:54 pm

    Hi Jordan,

    Great post. The issue I am running into is when users arrive on the form page via a direct link from an email. I assume the problem is since the user is arriving from an email the referer field is blank.

    I tried setting up another confirmation with conditional logic that when refer is blank to show a page instead. That did not work.

    1. David Smith
      David Smith Staff July 16, 2015 at 12:55 am

      Hi Michael, I tried setting a separate confirmation for when no referrer is set (like so) and it worked as expected. What issue were you running into with this approach?

    2. Michael Horwitz
      Michael Horwitz July 16, 2015 at 11:36 am

      Thanks David,

      I tried that approach and still got the error. I then exposed the Referer field and I saw that when I arrived directly on the page from an email the field was filled in with the page url itself after I hit submit. See screenshot.

    3. Michael Horwitz
      Michael Horwitz July 22, 2015 at 3:30 pm

      I figured it out.

      I was passing field data via query string from a previous form into a hidden(required) field. When directly referred from email the query string obviously wasn’t there to fill out the field hence the error with the submission. When I made the field non-required the form submitted successfully.

      Thank you for the assistance.

  14. alex
    alex July 9, 2015 at 8:00 pm

    Hello and thank you for the great tip! This works out of the box about 80%, however sometimes I’m getting a blank referrer entry, and sometimes it is returning the same url as the source page. Any idea for the inconsistency? Thank you again, Alex

    1. David Smith
      David Smith Staff July 10, 2015 at 7:05 am

      Hm, I haven’t had any issues with this in my own usage. Do you see any commonalities in the 20% that fail to capture the referrer? Have you found any way to even semi-consistently recreate the issue?

    2. alex
      alex July 10, 2015 at 9:53 am

      Thanks for the quick reply David. I have not been able to recognize a pattern yet. My assumptions are: 1) Maybe not capturing referrer url if user is on a mobile device? 2) The users are coming from job boards, ie, craigslist, monster, etc… perhaps some jobs boards mask the cookie (i don’t even know if that’s hoe GF auto-populates the info) 3) Maybe if they’re filling out the form and miss a required field, when they hit submit it clears out the that hidden field?

      Not sure, I’ll keep plugging away and let you know what I find. Thanks again

    3. David Smith
      David Smith Staff July 15, 2015 at 12:16 am

      Hi Alex, I tested for #3 and wasn’t able to recreate any issue there. #2 is unlikely since the referrer is almost always available in the page request (there are exceptions but I’ve never run into them). #1 Worked for me on mobile as well.

      These things can be annoying to track down. If you find a way to recreate, let me know and we’ll get it ironed out.

    4. alex
      alex July 16, 2015 at 1:05 am

      Thanks David, Yeah I’m still scratching my head over this, will keep trying to track down and report back. Take care.

  15. Manci
    Manci June 16, 2015 at 8:16 am

    Hello there, This is not working for me, I have create a hidden filed name{referer} and also place in {referer URl(hidden):4} in Redirect URL

    any help appreciated….

  16. Michelle Phillips
    Michelle Phillips June 5, 2015 at 5:21 pm

    Thank you so much for this helpful post! I just started using Gravity Forms and I was looking for a way to redirect the users to PayPal after completing a registration form. Your tutorial pointed me in the right direction and it all is working great. So thanks again :)

    1. Jordan Smith
      Jordan Smith June 6, 2015 at 1:11 am

      Hi Michelle,

      That’s great to hear! Thanks for taking the time to let us know you found this helpful!

  17. Adri Oosterwijk
    Adri Oosterwijk March 26, 2015 at 1:12 pm

    This is a truly great solution. Great in its simpleness. Thanks to Chris Hajer who point me in the direction of this tutorial. Was struggling an juggling with code for a whole day now and this tutorial sets me off in about 10 minutes. Including testing. GREAT, Thumbs up, 5 stars


Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.