# Referral Code in From Submission

**URL:** <https://community.gravityforms.com/t/referral-code-in-from-submission/1192>\
**Category:** Get Help\
**Tags:** dynamic-population, gform\_field\_value, query-string, cookie\
**Created:** [March 4, 2019, 6:07pm UTC](https://community.gravityforms.com/t/referral-code-in-from-submission/1192 "2019-03-04T18:07:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfishburn](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@dfishburn](https://community.gravityforms.com/u/dfishburn)\
**Post date:** [March 4, 2019, 6:07pm UTC](https://community.gravityforms.com/t/referral-code-in-from-submission/1192/1 "2019-03-04T18:07:45Z")

</div>

Our current “Non-Wordpress” website has a referral code system where we provide people a URL like “[www.website.com/?dref=ABC123](http://www.website.com/?dref=ABC123)” If someone clicks that link to our website, the “dref=ABC123” is stored as a cookie & if they end up submitting a form on our site that information is relayed within the form submission so we know where they came from.

I am building the new site in Wordpress & using Gravity Forms to handle all form submissions, is there something already out there that would allow me to do this easier or will I need to do something custom to work with the cookies.

Thanks for any assistance!

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [March 4, 2019, 6:35pm UTC](https://community.gravityforms.com/t/referral-code-in-from-submission/1192/2 "2019-03-04T18:35:56Z")

</div>

You can do that in Gravity Forms without the cookie. You can set up a field to be populated dynamically, and use the parameter name ‘dref’. When someone follows that link to your site the value of dref is stored in the form field. This explains how it’s done:

> **[Dynamically Populating a Field](https://docs.gravityforms.com/using-dynamic-population/#query-string)**
>
> This walk-through will give you and example of how to use each method of dynamic population to dynamically populate a field on your form!

If you have any questions, please let us know.

---

<div class="post-metadata">

**Author:** ![dfishburn](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@dfishburn](https://community.gravityforms.com/u/dfishburn)\
**Post date:** [March 4, 2019, 7:06pm UTC](https://community.gravityforms.com/t/referral-code-in-from-submission/1192/3 "2019-03-04T19:06:15Z")

</div>

Chris,

Does that work even if they don’t land directly on the form & submit a request right there. What if it’s just a link to our site & they view 15 pages before submitting the quote request?

Thanks!

---

<div class="post-metadata">

**Author:** ![chrishajer](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/chrishajer/32/88_2.png) [@chrishajer](https://community.gravityforms.com/u/chrishajer)\
**Post date:** [March 4, 2019, 8:21pm UTC](https://community.gravityforms.com/t/referral-code-in-from-submission/1192/4 "2019-03-04T20:21:15Z")

</div>

That will only work if they come to the form directly from the link. If you want to store it in a cookie when they arrive at your site, with that link, you can do that. Setting the cookie is not Gravity Forms functionality (you can use PHP or JavaScript to do that.)

Once you have stored that value in a cookie, you can read the value from the cookie and set the field value this manner:

> **[gform\_field\_value\_$parameter\_name](https://docs.gravityforms.com/gform_field_value_parameter_name/#2-populate-from-a-cookie)**
>
> This filter is executed before displaying each field and can be used to dynamically populate fields with a default value.

---

<div class="post-metadata">

**Author:** ![dfishburn](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@dfishburn](https://community.gravityforms.com/u/dfishburn)\
**Post date:** [March 4, 2019, 8:22pm UTC](https://community.gravityforms.com/t/referral-code-in-from-submission/1192/5 "2019-03-04T20:22:58Z")

</div>

Awesome! I’ll poke around some more with this & start testing out retrieving the cookie & populating the form with that data.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![richardw8k](https://sea2.discourse-cdn.com/flex020/user_avatar/community.gravityforms.com/richardw8k/32/2354_2.png) [@richardw8k](https://community.gravityforms.com/u/richardw8k)\
**Post date:** [January 4, 2022, 5:32pm UTC](https://community.gravityforms.com/t/referral-code-in-from-submission/1192/6 "2022-01-04T17:32:39Z")

</div>

Closed on January 4, 2022, 5:32pm UTC


