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.
xxxxxxxxxx
1
const url = document.referrer;
2
3
if (url) {
4
// as example `url` variable can be equal to 'https://google.com' when user came directly from google.com domain.
5
}
See also
0 commentsShow commentsAdd comment