-
-
Save nocodesupplyco/fbf9be812d7205d6da43c9a08b2bf6e2 to your computer and use it in GitHub Desktop.
Set Referrer URL as Hidden Input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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