Banner Stats
Overview
The Statistics Dashboard provides a comprehensive view of your advertising system's performance. It aggregates data from sponsors, banners, and placements to give you insights into impressions, clicks, click-through rates (CTR), and revenue.
Key Features
- Real-time Overview Statistics - Active sponsors, banners, zones, and performance metrics
- Performance Over Time - Daily statistics with 7, 30, and 90-day views
- Top Performers - Ranked lists of best-performing banners, sponsors, and zones
- Revenue Tracking - Monthly budget overview by sponsor
- Quick Navigation - Direct links to manage sponsors, banners, and zones
What Data is Tracked
tblBannerStats for time-based reporting.System Requirements
PHP Requirements
Required PHP Extensions
Required PHP Functions
Database Requirements
- MySQL 5.7+ / MariaDB 10.3+
- User must have SELECT permissions on statistics tables
- Aggregation functions:
SUM(),COUNT(),ROUND() - Date functions:
DATE(),DATESUB(),CURDATE()
External Dependencies
Page Layout
Header Section
The page header contains:
[Screenshot: Statistics page header]
Main Content Areas
The dashboard is organized into four main sections:
- Overview Statistics - Four summary cards at the top
- Performance Over Time - Daily statistics table (left, 2/3 width)
- Top Performers - Tabbed list of best performers (right, 1/3 width)
- Revenue & Quick Actions - Revenue stats and navigation (bottom row)
[Screenshot: Full statistics dashboard layout]
Overview Statistics Cards
Four summary cards provide at-a-glance metrics:
Active Sponsors Card
Data Source:
SELECT COUNT() FROM tblSponsors WHERE active = 1;
SELECT COUNT() FROM tblSubSponsors WHERE active = 1;
Active Banners Card
Data Source:
SELECT COUNT() FROM tblBannerAssets WHERE status = 'active';
SELECT COUNT() FROM tblBannerPlacements WHERE active = 1;
Total Performance Card
Data Source:
SELECT SUM(impressions), SUM(clicks) FROM tblBannerAssets;
-- CTR = (clicks / impressions) 100
Recent Activity Card
Data Source:
SELECT SUM(impressions), SUM(clicks)
FROM tblBannerStats
WHERE date >= DATESUB(CURDATE(), INTERVAL 30 DAY);
[Screenshot: Overview statistics cards]
Performance Over Time
The Performance Over Time section shows daily statistics in a table format.
Time Range Controls
Three buttons allow selecting the time range:
[Screenshot: Time range buttons]
Data Table Columns
CTR Color Coding:
- Green (#22c55e) if CTR >= 1%
- Orange (#f59e0b) if CTR < 1%
Data Source:
SELECT
DATE(date) as date,
SUM(impressions) as impressions,
SUM(clicks) as clicks,
ROUND((SUM(clicks) / SUM(impressions)) 100, 2) as ctr
FROM tblBannerStats
WHERE date >= DATESUB(CURDATE(), INTERVAL ? DAY)
GROUP BY DATE(date)
ORDER BY date ASC;
Empty State
If no data exists for the selected period:
[Chart icon]
No performance data available for the selected period
[Screenshot: Performance table with data]
Top Performers
The Top Performers section shows ranked lists of best-performing items with three tabs.
Tabs
[Screenshot: Top performers tabs]
Performer List Item Layout
Each item in the list shows:
Banners Tab Data
SELECT ba.title, ba.impressions, ba.clicks,
ROUND((ba.clicks / ba.impressions) 100, 2) as ctr,
s.name as sponsorname
FROM tblBannerAssets ba
LEFT JOIN tblSponsors s ON ba.sponsorid = s.id
WHERE ba.status = 'active' AND ba.impressions > 0
ORDER BY ba.clicks DESC
LIMIT 10;
Sponsors Tab Data
SELECT s.name,
SUM(ba.impressions) as impressions,
SUM(ba.clicks) as clicks,
ROUND((SUM(ba.clicks) / SUM(ba.impressions)) 100, 2) as ctr,
COUNT(ba.id) as bannercount
FROM tblSponsors s
LEFT JOIN tblBannerAssets ba ON s.id = ba.sponsorid
WHERE s.active = 1
GROUP BY s.id
HAVING impressions > 0
ORDER BY clicks DESC
LIMIT 10;
Zones Tab Data
SELECT bp.zonename,
SUM(ba.impressions) as impressions,
SUM(ba.clicks) as clicks,
ROUND((SUM(ba.clicks) / SUM(ba.impressions)) 100, 2) as ctr,
COUNT(ba.id) as bannercount
FROM tblBannerPlacements bp
LEFT JOIN tblBannerAssets ba ON bp.id = ba.placementid
WHERE bp.active = 1
GROUP BY bp.id
HAVING impressions > 0
ORDER BY clicks DESC
LIMIT 10;
Empty State
If no performance data exists:
[Chart bar icon]
No performance data available
[Screenshot: Top performers list with data]
Revenue Statistics
The Top Revenue Sponsors section displays sponsors ranked by their monthly advertising budget.
Revenue Item Layout
Each item shows:
Data Source:
SELECT s.name, s.monthlybudget,
COUNT(ba.id) as bannercount,
SUM(ba.clicks) as totalclicks
FROM tblSponsors s
LEFT JOIN tblBannerAssets ba ON s.id = ba.sponsorid
WHERE s.active = 1 AND s.monthlybudget > 0
GROUP BY s.id
ORDER BY s.monthlybudget DESC
LIMIT 10;
Empty State
If no sponsors have budgets set:
[Dollar sign icon]
No revenue data available
[Screenshot: Revenue statistics section]
Quick Actions
The Quick Actions panel provides direct links to related management pages:
[Screenshot: Quick actions panel]
Understanding Metrics
Impressions
Definition: The number of times a banner is displayed to visitors.
- Counted each time a banner renders on a page
- May include multiple views from the same visitor
- Higher impressions = more visibility
Clicks
Definition: The number of times visitors click on a banner.
- Counted each time someone clicks a banner
- Should redirect to the sponsor/advertiser's URL
- Revenue often tied to click counts
Click-Through Rate (CTR)
Definition: The percentage of impressions that result in clicks.
Formula:
CTR = (Clicks / Impressions) × 100
Benchmarks:
Monthly Budget
Definition: The advertiser's allocated monthly spending.
- Set per sponsor in sponsor management
- Used for revenue forecasting
- Does not affect banner display logic
Best Practices
Regular Monitoring
What to look for:
- Sudden drops in impressions (banner issues?)
- CTR changes (creative fatigue?)
- New top performers (successful campaigns)
Analyzing Performance
- Compare Time Periods - Use 7, 30, 90-day views to spot trends
- Check All Tabs - Review banners, sponsors, and zones separately
- Correlate with Changes - Did a banner change coincide with performance shifts?
Optimizing Based on Data
Data Accuracy
Troubleshooting
Common Issues
No Data Showing
Symptoms: All statistics show 0 or "No data available"
Possible Causes:
- No active banners in the system
- Banner tracking not implemented
tblBannerStatstable is empty
Solutions:
- Create and activate at least one banner
- Implement banner impression/click tracking in frontend
- Verify database tables exist and have data
-- Check if there's any data
SELECT COUNT() FROM tblBannerAssets WHERE impressions > 0;
SELECT COUNT() FROM tblBannerStats;
Page Loads Slowly
Cause: Large datasets with complex aggregation queries.
Solutions:
- Add indexes to statistics tables
- Consider archiving old data
- Increase
maxexecutiontimein php.ini
-- Useful indexes for performance
CREATE INDEX idxstatsdate ON tblBannerStats(date);
CREATE INDEX idxstatsbannerdate ON tblBannerStats(bannerid, date);
CTR Shows 0% Despite Clicks
Cause: Division by zero if impressions = 0
Solution: The code already handles this with:
CASE WHEN impressions > 0 THEN ROUND((clicks / impressions) 100, 2) ELSE 0 END
If still showing 0%, verify impressions are being tracked.
Revenue Section Empty
Cause: No sponsors have monthlybudget > 0
Solution:
- Navigate to Admin Panel → Advertising → Sponsors
- Edit sponsors and set their monthly budget
- Save and return to statistics
Top Performers Not Updating
Cause: Browser caching or data not being recorded
Solutions:
- Hard refresh the page (Ctrl+F5)
- Verify banner activity is being logged
- Check the AJAX responses in browser developer tools
Database Queries for Debugging
Verify Table Structure
DESCRIBE tblBannerStats;
DESCRIBE tblBannerAssets;
Check Recent Activity
SELECT DATE(date) as day, SUM(impressions), SUM(clicks)
FROM tblBannerStats
WHERE date >= DATESUB(CURDATE(), INTERVAL 7 DAY)
GROUP BY DATE(date)
ORDER BY day DESC;
Find Banners with Most Clicks
SELECT ba.id, ba.title, ba.clicks, ba.impressions,
s.name as sponsor
FROM tblBannerAssets ba
LEFT JOIN tblSponsors s ON ba.sponsorid = s.id
ORDER BY ba.clicks DESC
LIMIT 10;
Check for Data Gaps
-- Find days with no statistics
SELECT DATEADD('2024-01-01', INTERVAL n DAY) as date
FROM (
SELECT @row := @row + 1 as n
FROM tblBannerStats, (SELECT @row := -1) r
LIMIT 365
) numbers
WHERE DATEADD('2024-01-01', INTERVAL n DAY) <= CURDATE()
AND DATEADD('2024-01-01', INTERVAL n DAY) NOT IN (
SELECT DISTINCT DATE(date) FROM tblBannerStats
);
Translatable Strings
The following strings should be added to backendtranslations.md for internationalization:
Page Title and Navigation
statisticstitle = "Statistics Dashboard"
statisticssubtitle = "Monitor performance, track metrics, and analyze sponsor engagement"
breadcrumbstatistics = "Statistics"
Overview Cards
statactivesponsors = "Active Sponsors"
stattotalactivesponsors = "Total Active Sponsors"
statsubsponsors = "sub-sponsors"
statactivebanners = "Active Banners"
statlivecampaigns = "Live Banner Campaigns"
statactivezones = "active zones"
stattotalperformance = "Total Performance"
stattotalimpressions = "Total Impressions"
statclicks = "clicks"
statctr = "CTR"
statrecentactivity = "Recent Activity"
statimpressions30days = "Impressions (30 days)"
Performance Section
sectionperformanceovertime = "Performance Over Time"
btn7days = "7 Days"
btn30days = "30 Days"
btn90days = "90 Days"
tabledate = "Date"
tableimpressions = "Impressions"
tableclicks = "Clicks"
tablectr = "CTR"
Top Performers Section
sectiontopperformers = "Top Performers"
tabbanners = "Banners"
tabsponsors = "Sponsors"
tabzones = "Zones"
bysponsor = "by"
bannercount = "banners"
Revenue Section
sectiontoprevenue = "Top Revenue Sponsors"
Quick Actions Section
sectionquickactions = "Quick Actions"
actionmanagesponsors = "Manage Sponsors"
actionmanagebanners = "Manage Banners"
actionaddbanner = "Add New Banner"
actionmanagezones = "Manage Zones"
Empty States
emptynoperformance = "No performance data available"
emptynoperformanceperiod = "No performance data available for the selected period"
emptynorevenue = "No revenue data available"
Loading States
loadingstatistics = "Loading statistics..."
loadingchart = "Loading chart data..."
loadingperformers = "Loading performers..."
loadingrevenue = "Loading revenue data..."
Error Messages
errorloadingoverview = "Error loading overview stats"
errorloadingperformers = "Error loading top performers"
errorloadingdaily = "Error loading daily stats"
errorloadingrevenue = "Error loading revenue stats"
errorinvalidcsrf = "Invalid CSRF token"
errorinvalidtype = "Invalid type"
Navigation Buttons
navsponsors = "Sponsors"
navbanners = "Banners"
navaddbanner = "Add Banner"
navbannerzones = "Banner Zones"
navsubsponsors = "Sub-Sponsors"
navstatistics = "Statistics"
Related Documentation
- Banner Management - Manage banner ads
- Add Banner - Create new banners
- Banner Zones - Manage placement zones
- Sponsors Management - Manage sponsors
- Sub-Sponsors - Manage sub-sponsors
Changelog
This documentation is part of the ComusThumbz Admin Guide series.