EN
JavaScript - how to detect from where user came?
1
answers
8
points
I am looking for the best way how to detect from where user came to my web page.
I know there is referrer header in HTTP protocol. Is it possible to get in JavaScript in web browser that kind of information?
1 answer
10
points
Yes, it is possible. Use document.referrer property.
e.g.
const url = document.referrer;
if (url) {
// as example `url` variable can be equal to 'https://google.com' when user came directly from google.com domain.
}
See also
0 comments
Add comment