Skip to content

Instantly share code, notes, and snippets.

@kaesetoast
Created April 14, 2020 09:24
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 kaesetoast/7086f3a7a665d69936aeb8334774a35b to your computer and use it in GitHub Desktop.
Save kaesetoast/7086f3a7a665d69936aeb8334774a35b to your computer and use it in GitHub Desktop.
// check if referrer is outside of the website scope
if (document.referrer.indexOf(`${window.location.protocol}//${window.location.host}`) === -1) {
window.localStorage.setItem('__fnp_referrer', document.referrer);
}
const referrerField = document.querySelector('[name="signupform[referrer]"]');
const referrerValue = window.localStorage.getItem('__fnp_referrer');
// write stored referrer value back to hidden field in signup-form
if (referrerField && referrerValue) {
referrerField.setAttribute('value', referrerValue);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment