Pre-populating Users' Unique Referral Codes In Signup Flows & Forms
A how-to guide for ensuring a user's unique referral code is pre-populated in your signup flow or form when they share their unique referral link.
Last updated
A how-to guide for ensuring a user's unique referral code is pre-populated in your signup flow or form when they share their unique referral link.
Last updated
The most frictionless way for a user to share a referral code is when they share a link to your signup flow or form that pre-fills their unique referral code in your signup flow's referral code field. You're able to configure this with Village's referrals setup.
Go to Side Menu > Referrals > Create New Referral
Mark 'Create a unique link and code for users'
You'll see this input:
When creating the referral program, point 'https://your-url.com/signup/' to your domain's signup specific landing page. This will ensure that the referral link that is shared by a user will point at your landing page.
If you want the user's code to be pre-filled in the referral code field in your signup form, you will generally have to modify the code of your web page and use a server-side or client-side programming language, like JavaScript, to parse the URL and fill in the referral code field automatically when the page loads.
Structure your URL such that the referral code can be passed as a query parameter, eg: https://your-url.com/signup/?referral_code={your_code}.
Ensure your referral code field in the signup form has a unique ID so that it can be selected using JavaScript. For example:
Parse the URL and set the value of the referral code field. Use JavaScript to parse the URL and pre-fill the referral code field when the page loads. Eg. add this script to your web page:
Back in Village, input the URL you created in step 5. above into the unique link field when creating a new referral structure in Village:
User goes to the URL when a referral code generated in Village is shared. Eg. https://your-url.com/signup/?referral_code={your_code}. The 'your_code' part is generated as a unique code for each user in Village.
The JavaScript code reads the referral_code
parameter from the URL.
If a referral code is found, it sets the value of the referral code input field with the ID referralCode
to the read referral code.
Pre-populating a referral code in a Google Form field is relatively straightforward.
Go to Side Menu > Referrals > Create New Referral
Mark 'Create a unique link and code for users'
Go to the Google Form where you want to pre-propulate the referral code when shared. Make sure you have a 'Referral Code' field created in the form.
Click on the three vertical dots in the top right corner of the form. Select “Get pre-filled link.”
Fill out the form with the values you want to be pre-filled. In this case, write something like 'prefilled_value' into the 'Referral Code' field and leave the other fields blank.
Click on “Get Link” at the bottom right.
Copy the provided URL; this is your pre-filled form link.
The URL you copied will look something like this:
Back within Village, replace 'https://your-url.com/signup/' in the unique link input field with the link you copied, replacing 'prefilled_value' with '{your_code}'. It should look something like: 'https://docs.google.com/forms/d/e/[FORM_ID]/viewform?usp=pp_url&entry.[FIELD_ID]={your_code}'
Create and test the link. If it is working successfully, when you enter the link, it should direct to your form with '{your_code}' prefilled in the Referral Code field.
When a user copies and shares their referral code link on their dashboard generated with this referral program, it will direct those they share it with to your Google Form signup with their unique code prefilled. Make sure you test this.