If we find out that most
of our users do not go past the first page in the ordering process, we know there is
something wrong. We need to simplify the workflow.
Collecting user behavior data can allow us to generate intelligence out of the data. It
will help us evolve our best practices and increase user satisfaction. Now we can use
the web server logs for tracking page views. But we get full flexibility with our own
tracking system. How can we set up a simple tracking system for POTR? The job is
very easy for us because we have a centralized architecture. Let's see how we can do it.
Time for Action: Implementing User Tracking
1. Create a new table in the database. The following code shows the schema.
You may use phpMyAdmin or any other database administration tool to
do this.
CREATE TABLE `trackingdata` (
`id` int(10) unsigned NOT NULL auto_increment,
`userId` int(10) unsigned NOT NULL,
Chapter 5
[ 95 ]
`sessionId` varchar(40) NOT NULL,
`accessTime` timestamp NOT NULL default CURRENT_TIMESTAMP,
`action` varchar(20) NOT NULL,
`page` varchar(255) NOT NULL,
`referer` varchar(255) NOT NULL,
`browser` varchar(200) NOT NULL,
`timeSpent` int(6) unsigned NOT NULL,
`vars` text NOT NULL,
PRIMARY KEY (`id`)
) ;
2.
Pages:
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135