Using a User Session class we can collect data for analysis, once the data is collected we need to analyze and store the relevant data to provide useful reports, that can be used for marketing, SEO and other functions.
Storing the Data
To store the data I decided to use several tables, this covered:
- Location – By City/Month
- Sales – By City/Month
- Page View – By Month
Further breakdown’s could be made, almost certainly on page view’s by day or week, however, this level of data could have increased the database size exponentially, especially so if the website contains hundreds of product pages.
For hourly, daily, weekly and monthly data, the tables all contained the following fields:
- Total Visits
- Human visits
- Mobile Visits
- Bot Visits
- Bounced visits
- Total Pages Viewed
- Total Sales amount
- Number of conversions
- Number of mobile conversions
- Unknown Referrer
- Direct Referrer
- Organic Referral
- Bing Referral
- Google Referral
- Yahoo Referral
- Facebook Referral
- Twitter Referral
Also included were individual fields for the type, for instance monthly contained a month and a year etc.
Processing the numbers
The actual processing of the user session data is done in stages, it must pass each stage before it reaches the end of the process and can be deleted or archived.
The individual stages are:
- Stage 1 – Extract hourly data.
- Stage 2 – Update initial referrer counts.
- Stage 3 – Extract page data.
- Stage 4 – Update monthly sales data.
- Stage 5 – Update location data.
- Stage 6 – Update daily data.
- Stage 7 – Update monthly data.
- Stage 8 – Update weekly data.
- Stage 9 – Delete data that is completely processed and one year old
The range of reports producible from the above data collecton is many-fold, below are a few reports found on a basic report page.