0

I am working on building some internal analytics for my site. Often, people come to the site, and don't do much else on the site, and I am curious whether these are possible:

Can I tell what site they went to when they left my site, or whether they pressed the back button?

Or any practical advice for figuring out what the user behavior was would be great.

I am using PHP by the way.

Thanks!!

GeekedOut
  • 16,905
  • 37
  • 107
  • 185

3 Answers3

2

You can (somewhat reliably) tell where they came from, using $_SERVER['HTTP_REFERER'], including sites they came from before first visiting your site. If they used the Back button to move from one of your pages to another, you could detect that, depending on whether their browser sends that header, but you'd have to keep track of the "last page visited" in the session.

You can not, however, tell what site they went to when leaving your site. This would be really bad for many reasons, if it were possible.

FtDRbwLXw6
  • 27,774
  • 13
  • 70
  • 107
  • what about if they came from google, and then clicked the back button - is that possible to detect? – GeekedOut Feb 01 '12 at 18:03
  • @GeekedOut: If the user's browser sends the referer header, then you could tell that the user came from Google. That's about it. – FtDRbwLXw6 Feb 01 '12 at 18:13
1

You could use an Analytics tools like Piwik or Google Analytics. They give you great information on your users behavior and are easy to integrate. No need to code this at your own.

You can track, if people click on links to external sites - but you cannot track, if someone just leaves your site entering a new url to his address bar.

EDIT

You already use Google Analytics. Have a look into event tracking. This can help you to track people clicking external links on your site and leaving it that way. Tracking the back-button of your browser is also possible.

I think you are especially interested in people, visiting your site and directly clicking the back button, going back to Google (or any other referring site). This user behavior is called "bouncing" and it is a very important key metric to judge the quality of your site. Google Analytics shows you the bounce rate for every page on your site. 30% means, 30% of the users entering your site on this specific page leave it directly, w/o viewing another page of your site.

Community
  • 1
  • 1
DerVO
  • 3,679
  • 1
  • 23
  • 27
  • I already use Google Analytics, but that information isn't enough to really get a sense of the nature of user experience. How is piwik different? Thanks! – GeekedOut Feb 01 '12 at 18:04
  • piwik is open source and you dont need to give your data to google. Appart from that, it's a similar tool. And it's not as mighty as GA is. – DerVO Feb 01 '12 at 18:16
1

You can use a tool like CrazyEgg to see where people are clicking. It may help you figure out whether you have any usability issues in your site.

Note some privacy software can munge or even remove the referrer from the client's HTTP headers. This behavior tripped my team up on a couple of projects, and if a user has such software enabled, there's nothing you can do on your end to rectify it. (You should keep this in mind as you code - it's an edge case, but possible)

Also note that the referrer won't be populated if a user typed in your site's URL. I'm pretty sure browsers only populate a referrer when a link is clicked.

Tim
  • 4,051
  • 10
  • 36
  • 60