How Can I Detect Where Users Are Coming From?

0
12
Asked By CuriousCoder92 On

Hey everyone, I'm curious about how to find out which website a user came from before landing on mine. I stumbled upon this Stack Overflow question that mentions using the 'referrer' parameter, and I checked the MDN docs on it. However, when I tried it in the console after clicking the link, it returned an empty string, even though the documentation says it shouldn't. Can anyone shed some light on this? Does it actually work?

5 Answers

Answered By CodeNinja7 On

When you say you 'entered this link,' do you mean you just typed it in? If so, the referrer will be blank since no site referred you. The referrer header usually only gets passed when clicking a link from another site. Plus, some external sites can block it using referrer policies. Check it out here: https://developer.mozilla.org/en-US/docs/Web/Security/Referer_header:_privacy_and_security_concerns

Answered By WebWizard88 On

You should check the 'Referer' header! This is what passes along the info about where users came from. Here’s the link to the MDN docs for more details: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Referer

DevDude42 -

Just a heads up, the misspelling of 'referer' is actually how it was specified in the old standards. It might confuse non-developers.

Answered By Techtastic101 On

Booooo! 😂 Just kidding, the referrer can be tricky business!

Answered By SmartCoder22 On

It's good to know you can pull the Referer header directly, but keep in mind that it's not very reliable. Browsers often block this for security reasons—which is actually a positive thing! Just something to consider when planning your approach.

Answered By AnalyticAce11 On

Yep, it’s called the referrer website or page. Most analytics tools track this info, but it's built into the request headers, so you don't need third-party tools to access it. Just keep in mind that it's optional; not all sites will provide it.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.