Tracking Website Visitors with Cookies

Sun and Netscape's web servers have always provided a request-processing "toolkit" of sorts. Over the years, the size of that toolkit has grown. Sun Java System Web Server 7, in particular, adds a number of new tools to the toolkit.

Four of the new tools in Web Server 7 — the <If> tag, $cookie{...} map variable, uuid() expression function, and set-cookie SAF — can be used together to track visitors like the Apache mod_usertrack module does.

For example, you could add the following below the <Object name="default"> line in the obj.conf configuration file to give each visitor a unique VISITID cookie that lasts until they close their web browser:

<If not defined $cookie{'VISITID'}>
ObjectType fn="set-cookie" name="VISITID" value="$(uuid())"
</If>

Since each visitor will now have his or her own cookie, you can identify individual users in your access logs by including the $cookie{'VISITID'} variable in the access log format. For example, you might specify the following in the server.xml configuration file:

<access-log>
  <file>../logs/access</file>
  <format>"%Req->reqpb.clf-request%" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length% "$cookie{'VISITID'}"</format>
</access-log>

The toolkit approach to configuration is powerful, but it also means the best way to configure specific functionality isn't always obvious. Please let me know if you ever have an idea for an obscure, exotic, or complicated Sun web server configuration task. I hope I'll be up to the challenge... :)

Comments:

Hi,

I tried this, but when I check my access log I see "-" where I expect the cookie information to be. Any ideas? Otherwise, I think it's such a great idea. I'm using WS 7.0 Update 1 btw.

thanks,
Rob

Posted by Rob Terro on August 16, 2007 at 06:12 AM PDT #

Hey,

I tried the following syntax in my SunONE Web server 7. I can able to see the "$cookie{'VISITID'}" values in the web server access log..

Here is the steps which I followed...

I edited the obj.conf file tags..

and

I edited the server.xml to change the access log format..

It worked with the following output..

"GET /img/oracle_logo.jpg HTTP/1.1" 304 0 "0ed338d4-02a9-4380-84d5-9439d4e3db07"
"GET /img/oiws_title_text.gif HTTP/1.1" 304 0 "0ed338d4-02a9-4380-84d5-9439d4e3db07"
"GET /img/a.gif HTTP/1.1" 304 0 "0ed338d4-02a9-4380-84d5-9439d4e3db07"
"GET /img/content_hline.gif HTTP/1.1" 304 0 "0ed338d4-02a9-4380-84d5-9439d4e3db07"
"GET /img/footer.gif HTTP/1.1" 304 0 "0ed338d4-02a9-4380-84d5-9439d4e3db07"
"GET /img/footer_L.gif HTTP/1.1" 304 0 "0ed338d4-02a9-4380-84d5-9439d4e3db07"
"GET /img/footer_R.gif HTTP/1.1" 304 0 "0ed338d4-02a9-4380-84d5-9439d4e3db07"

Great... Thank you elving

Srinivasan

Posted by Srinivasan Ramasamy on September 07, 2010 at 12:40 PM PDT #

Hi,

Any one can help me to find out the access logfile parsing to count the Unique session ids which are generated by the "$cookie{'VISITID'}" entries..

Thank you advance for your help..

Thank you,
Srinivasan

Posted by Srinivasan Ramasamy on September 07, 2010 at 12:43 PM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

elving

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today