/    Sign up×
Community /Pin to ProfileBookmark

How to do user tracking

Hi All

I ve a need to track and record all the movements in a website by any user.
By movements I mean which all webpages the user visited in the website
I m not gettin any headway in it. If anyone have done this before can u plz discuss that here

Plz help

Arpan

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@DaiWelshMay 16.2006 — That is too big a question for anyone to answer directly. What level of information do you need to store? What will you use it for?

You can write every (php) page hit into a database table by including a function at the top of every page on your site, using items from the $_SERVER array to get the information you need. If you need to tie the hits together for each user then you will want to combine this with a session or cookie based approach to identifying individual users in the first place.

However any method for tracking at a user level will be unreliable so again it depends what you want and why.

Also, it may be that the level of information you require is better retrieved from the web server logs, either by your script or using a standard web stats package.

HTH,

Dai
Copy linkTweet thisAlerts:
@HuevoosMay 16.2006 — statcounter.com in the stats it displays the pages which every user visited by ip
Copy linkTweet thisAlerts:
@arpan_biswasauthorMay 17.2006 — Thks for the response....

As per my requirement I ve to collect the info as an admin to generate a report .... which pages are frequently been visited by the users.

Pages visited can be search criteria as well

For this I had also thought of the same which u r suggesting i.e call the function at the begining of every page to add/update record for the page visited. I don't have any relevance for user so I was not considering cookies for this.

The issues which I feel would come up for the common function would be .... my website can become comparitively slow. Is there any method which I can use to do background query execution . I ve thought of pcntl_fork() to connect and execute query as a child process..will that be helpful or is there any better way to do this

Now I hope my requirement is clear

Can u suggest how should I move forward

Regards

Arpan
Copy linkTweet thisAlerts:
@themartyMay 17.2006 — All you need is 1 extra query per page. I don't think it would make your website that much slower.

What you could do, to identify users, is the following:

create two tables in your database

  • - visitors (visitorID, ip)

  • - pageVisits (visitorID, page, visitDate)


  • On each page start a session (session_start()) and then check if $_SESSION['visitorID'] exists.

    If it doesn't, do an insert in the visitors page and use mysql_insert_id() (if you're using mysql) to obtain that visitor's id (and assign it to $_
    SESSION['visitorID']). (a nice side-effect is that that number will also indicate how many visitors you've had). That you will only have to do once.

    After that, just insert that id, the requested page and the date (the visitDate field should be of the type DATETIME) into the pageVisits table. With that info you should be able to create some nice stats.

    And of course you can record a lot more in that table (GET variables, etc.)
    ×

    Success!

    Help @arpan_biswas spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...