Forum Moderators: open

Message Too Old, No Replies

Can script detect clicks from links from a local HTML file?

Detecting the origin of visits

         

espressow

11:56 pm on Aug 27, 2018 (gmt 0)

5+ Year Member



I know that Google Analytics detects visits from a bookmark or typed URL versus a link from a website. Can Javascript or another means detect the difference between a bookmark click and a typed address?

Also, if the link is in a local html file on my computer and I click it, will the site be able to detect that it was a click from another "site" page versus instead of a bookmark or typed URL?

If I highlight a URL on a page that is not a link (just text), right click and choose "Go to...", will that register as a link from another site or a typed URL?

MichaelBluejay

5:14 pm on Sep 2, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The answer to your questions is no: That kind of extra information about where a visitor came from isn't available.

You're talking about what "Javascript" can detect, but Javascript doesn't detect anything. Javascript merely accesses the hidden data that's available in every web page, such as where the visitor came from. The visitor's source page is called the "referrer". The "referrer" either has a value (the web page the user click over from) or it's blank (e.g. typed-in addresses). There are no "extra" details about where the visitor came from.

You can test your questions yourself by making a page with this HTML:

<button onclick="alert(document.referrer)">test</button>


Doing that, the referrer was blank in all of the scenarios you mentioned (entering from a typed-in address, a bookmark, a link in a local file, and a right-click on a selected text (unlinked) url to Go to URL).

lucy24

6:15 pm on Sep 2, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Rather than speculate, I went to my site logs and searched in this form:
GET /piwik.+?(file|local)
using both forms because I wasn't sure what I was looking for.

If you save a file to your local HD and neglect to delete the analytics code, then the site owner will see when you access the file. (Knowing this, I always delete analytics when I have occasion to save a page locally.) The actual log entries were, of course, percent-encoded. I’ve decoded them to make it easier to read.
86.41.cc.dd - - [31/May/2018:17:44:55 -0700] "GET /piwik/piwik.php?action_name=Children of the Abbey&idsite=3&rec=1&r=310617&h=1&m=44&s=55&url=file:///mnt/120A52010A51E271/Mike_files/eBooks/children-of-abbey.html& [et cetera]

108.171.cc.dd. - - [14/May/2018:13:56:25 -0700] "GET /piwik/piwik.php?action_name=Clothing from Point Barrow&idsite=3&rec=1&r=571013&h=15&m=56&s=23&url=file:///C:/Users/US067127/Documents/2014 Clothing from Point Barrow.html& [et cetera]

79.64.cc.dd- - [11/Apr/2018:13:10:39 -0700] "GET /piwik/piwik.php?link=file:///ebooks/paston/&idsite=3&rec=1&r=558980&h=21&m=10&s=39&url=http://example.com/ebooks/paston/paston6b.html [et cetera]

Dunno about GA, but piwik/matomo records two different referers: the immediate referer (same as what's sent in the “Referer” header) that led you to the current page or fragment, and the original referer that first brought you to the site on your original visit. Either or both of those could be a file:// rather than the more common http(s)://