Skip to content

Instantly share code, notes, and snippets.

@nocodesupplyco
Created December 19, 2022 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nocodesupplyco/fbf9be812d7205d6da43c9a08b2bf6e2 to your computer and use it in GitHub Desktop.
Save nocodesupplyco/fbf9be812d7205d6da43c9a08b2bf6e2 to your computer and use it in GitHub Desktop.
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