0

im new on stackoverflow, so don't be harsh xD

Im still learning and there is so much that i dont know yet

Im currently developing a website and got stuck with a question: how to make a website perform differently if it was accessed via a QR code?

For example if a person gets to a website through QR code they can see a button, but if a person gets to a website through copying url or searching through the web, then there is no button.

I have looked through the web, W3 and stackoverflow, but couldn't find anything that could be similar, hence thats the reason why im here =)

The only thing that i found was (see below), however im not sure it has any use for my idea

var referrer = document.referrer

I dont use php and have no idea of how to use it, hence no php please =)

  • 3
    Make the URL that the QR code generates include a query parameter, and check for that. – Barmar Feb 08 '22 at 08:57
  • 1
    No method will be bullet-proof, since users can always force the browser to send anything they want in the request. – Barmar Feb 08 '22 at 08:58
  • Add a string to your url and detect it with js like mysit.com/qrcode and use this https://stackoverflow.com/questions/4597050/how-to-check-if-the-url-contains-a-given-string – Grumpy Feb 08 '22 at 08:59
  • Scanning the QR code and telling the app to open the link will be no different from somebody typing the URL into a browser's address bar manually as far as the referrer is concerned, so a very basic way would be to add something like `?qr=yes` to the end of the URL. This can be detected by PHP/node/whatever your server is using or client-side JS. However it can of course easily be added manually. If this is just for statistical purposes or something, that should be fine. –  Feb 08 '22 at 09:02
  • @ChrisG He stated, no php/ – Grumpy Feb 08 '22 at 09:59

0 Answers0