What I want to know is when people click on a link on my site (internal link - not on other websites), if they just clicked on it or clicked on it (or right-click - open in a new tab )
I am using PHP.
So, an example: The person is on page 1 and click on the link for page2. When they are on page2, I want to know where they came from (_server ['http_referer'] gives me this), but I also want to know if they opened the page in a new window / tab. I need to know this because of the history return button on the page.
The reason for this is to know the browsing history around the site - I create a session to track browsing history (so that I can return one page back, two pages back or three pages back at any given time), but I donβt need to Sessions conflict between tabs so that each tab has its own browsing history. This is why I need to create a new session for each open tab.
What I found as a possible solution to my problem is to use javascript like this:
<script> var history_status = history.length; var referrer_site = document.referrer; if(history_status > 1 && referrer_site != "") { alert(referrer_site); } else { alert('No referrer site'); } </script>
I need to change it a bit, but this was my first demo to check if it works (and it was)
First I need to find what the browser uses, because history_status gives 0 for the first page of the story when you use IE, but 1 if you use Firefox or Chrome.
source share