Tracking site visitors (with cookies?)

I am looking for a way to track what pages on my website a visitor has looked at, and include that list if they then send me a message using the contact form. Is that possible?

Bear in mind that:

  • I know nothing about the technicalities of how cookies work
  • The site is written in SHTML

I am not bothered about tracking visitors across sessions, it’s only to see the pages they looked at leading up to using the contact form. It isn’t essential, so a method that works for 90% of people but not 100% is fine.

I’ve tried Googling, but starting from a point of ignorance I couldn’t find anything that seemed relevant. Any help would be much appreciated!

I’m sure its possible with some php, possibly using $_SERVER['HTTP_REFERER'] to add to an array on each page and put it in the session. Depending on how many form mails you get, an easier option may be to use Google Analytics to see what pages they looked at.

That sounds like it might be complicated, especially if it involves switching all pages to PHP…

Is it straight-forward to get that list of URLs from Google Analytics appended to a contact form? As usual when I google anything developery, I don’t have the faintest idea of what websites I should be looking at and most of them are talking complete gobbledegook … or in the case of GA, usually trying to get me to sign up to something.

I have no idea about that.

Maybe it could be done in shtml, but I don’t know shtml.

Hey Stevie,

One way you might do this is to use some kind of client side storage (cookies, local storage, or whatever) to keep track of where your visitors have been during a session. Then, when they land on your contact form page, append this information (if retrievable) to a hidden input in the contact form.

You can also track this kind of thing with Google Analytics. You’d need to look into how to implement it, but I think Visitor Flow is what you should be looking at.

The first solution is a bit quick-n-dirty. If you need to do this for any kind of reporting purposes, I would invest a little time in learning how to set up and track stuff with GA.

Yes, that was the kind of thing I was looking for, but I have no idea where to start with cookies, and I’ve not been able to find any resource on the web that give instructions that are non-technical enough for me to follow…

It really is just to see which pages people have been to before contacting me, rather than for any other reporting purpose. I am trying to avoid using GA unless it’s the only option, because it annoys me on other websites when it causes them to run slowly.

I would recommend this:
I can help you with the implementation if you would like.

Hop of the high-horse and use Google Analytics like everyone else is using. Its free, well documented, backed by a tech giant, flexible, and there are a mountain of resources. You said it yourself you know nothing about this stuff but I can tell you Google knows ALOT about it.

Will also tell you things like how many visitors are using mobile devices. for example you might want to consider a site upgrade if you see everyone on a mobile leaving before hitting your contact form. It’s going to be your simplest option as you just cut and paste code into your pages.

Thank you for your helpful and constructive suggestion. No acknowledgement that the wisdom of the masses might not be all that wise, no recognition that I don’t want to give my users a worse experience which your recommendation would do, no consideration that I might not want the features that Google Analytics offers. But patronising, yes you’ve managed that one just fine.

I’ve looked into this, but haven’t used it.

You could probably use Local Storage. It is supported on a lot of browsers. You could just append the current URL/Page Name/Whatever to a JSON array then store that, then submit that with the contact form. You have 4mb of storage, so don’t store the entire URL, just the minimum required like window.location.pathname or something.

I just can’t over the fact that you believe a single JavaScript file or two from Google is going to have any noticeable performance implications. Especially when millions of sites use the EXACT same script and function just fine. You’re completely over thinking this for no other reason than a false sense of negative performance implications. You are effectively wasting your time and your clients money by being so stubborn and failure to conform to a well known standard.

While there are no performance implications to GA, it does use Cookies.

But I agree that if you want real page tracking, you should have analytics. Be it GA or Piwik or Statcounter or something else. It’s invaluable information.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.