Forum Moderators: phranque
I would like to run a tracking script for every request made by a visitor (based on some simple criteria like if it's not a css file or an image etc).
Here is the real catch - I would like to capture the php session ID and current URI of the user so that I can do clickpath analysis. My preference would be to run a php file for every "page" request that does all of this for me, but I don't know how to set this up in my .htaccess file. I'm thinking that if I could tell apache to run a script and pass in some environment/session vars (like session and URI) I would be set.
I don't want to do this in a header or footer file as I want to track pdf's and HTM's as well and I don't want to do redirects or some such nonsense.
Any ideas? Am I skinning this particular cat in the wrong direction?
[edit - one note]
Perhaps I could set this up as an additional logging mechanism? Sort of like some folks pass their log entries thru a script instead of logging them directly - only I don't want to disturb my current logging, just perhaps add another logging method..
Thanks!
Bill
1) does it have to be based on PHP session ID, or will mod_unique_id [httpd.apache.org] give you what you need?
2) Apache 2.0.x supports logging cookies using mod_log_config [httpd.apache.org], which would allow you to log the PHPSESSID cookie contents.
Of course, you can always write your own module (or modify an existing one) to meet your needs, or even use mod_perl [perl.apache.org].
I have decided to just parse the logs for this data.
But for completeness, here is what I did:
in httpd.conf include (or in the file itself):
CustomLog "¦/bin/log.cgi" extended
Then in log.cgi:
#!/usr/bin/perl
open(MYOUTFILE, ">>/var/log/out.txt");
while(<STDIN>){
my $line = $_;
chomp ($line);
print MYOUTFILE $line . "\n";
}
I guess I would do some setenvif stuff to filter out image requests, but I'm not sure I could ever get the session id in there.
Thanks for all the suggestions :)
Bill
[edited by: jdMorgan at 8:15 pm (utc) on July 11, 2005]
[edit reason] Disabled smily faces in code. [/edit]