Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Created December 19, 2022 16:45
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Set Referrer URL as Hidden Input
// Make a reference to the form field
const hiddenField = document.getElementById('hidden-field');
// Get the referrer domain
const referrer = document.referrer.split('/')[2];
// If there is a referrer then set the field value
if (referrer) {
hiddenField.value = referrer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment