A comprehensive web analytics application built with PHP and W3.CSS for tracking page views, user behavior, and website statistics.
- Page view tracking with browser and OS detection
- Admin panel with asset management and statistics
- Real-time analytics dashboard with filtering
- CSV export functionality
- User management with role-based access
- Responsive design with W3.CSS framework
- PHP 7.4+
- MySQL 5.7+
- Web server (Apache/Nginx)
- Create MySQL database
brickmmo_stats - Import
setup.sql - Configure database in
includes/config.php - Access via web browser
- Username:
admin - Password:
password
- Login to admin panel
- Create new asset
- Copy tracking code snippet
- Add to your website
<script src="tracker.js" data-asset-id="1"></script>admin/ # Admin panel
includes/ # Core PHP files
demo/ # Demo website 1
demo2/ # Demo website 2
tracker.js # Tracking script
track.php # Tracking endpoint
setup.sql # Database setup
assets- Website tracking configurationsstats- Page view tracking datausers- Admin user accounts
POST /track.php
{
"asset_id": 1,
"url": "https://example.com",
"browser": "Chrome",
"os": "Windows 10",
"referrer": "https://google.com"
}Tarun Shokeen - HTTP 5310 Capstone Project DB_HOST=localhost DB_USERNAME=root DB_PASSWORD=your_password DB_DATABASE=brickmmo_stats
4. **Access the Application**
- Open `http://localhost/BrickMMO_stats-v1/` in your browser
- Login to admin panel: `http://localhost/BrickMMO_stats-v1/admin/`
- Default credentials: `admin` / `password` (change immediately!)
## π Usage
### Creating a New Asset
1. Login to the admin panel
2. Navigate to "Assets" β "New Asset"
3. Enter asset name and description
4. Copy the generated tracking code
5. Paste into your website's HTML
### Tracking Code Integration
#### Method 1: Basic Script Tag
```html
<script src="/BrickMMO_stats-v1/tracker.js" data-asset-id="1"></script>
<script>window.BRICKMMO_ASSET_ID = 1;</script>
<script src="/BrickMMO_stats-v1/tracker.js"></script><script src="https://cdn.brickmmo.com/stats/tracker.js" data-asset-id="1"></script>- Access the admin panel
- Navigate to "Stats" to view all analytics
- Filter by specific assets using the dropdown
- View detailed breakdowns by browser, OS, and referrers
- Export data for further analysis
BrickMMO_stats-v1/
βββ admin/ # Admin panel files
β βββ index.php # Dashboard
β βββ login.php # Authentication
β βββ assets.php # Asset management
β βββ stats.php # Statistics viewer
β βββ users.php # User management
β βββ auth.php # Authentication functions
βββ includes/ # Core PHP files
β βββ config.php # Configuration
β βββ connect.php # Database connection
β βββ functions.php # Utility functions
β βββ header.php # HTML header
β βββ footer.php # HTML footer
βββ tracker.js # JavaScript tracking script
βββ track.php # Tracking endpoint
βββ index.php # Main landing page
βββ setup.sql # Database setup script
βββ .env # Environment variables
βββ README.md # This file
id: Unique asset identifiername: Asset display namedescription: Optional descriptionsnippet: Generated tracking codecreated_at: Creation timestamp
id: Unique tracking record IDasset_id: References assets tableurl: Tracked page URLip_address: Visitor IP addressbrowser: Detected browseros: Detected operating systemuser_agent: Full user agent stringreferrer: Referring URLviewed_at: Tracking timestamp
id: Unique user IDusername: Login usernamepassword: Hashed passwordrole: User role (admin/user)created_at: Account creation date
Receives tracking data from JavaScript and stores in database.
Request Body:
{
"asset_id": 1,
"url": "https://example.com/page",
"browser": "Chrome",
"os": "Windows 10",
"referrer": "https://google.com",
"screen_width": 1920,
"screen_height": 1080,
"viewport_width": 1200,
"viewport_height": 800,
"timezone": "America/New_York",
"language": "en-US"
}Response:
{
"status": "success",
"message": "Tracking data saved successfully",
"insert_id": 123,
"asset_id": 1
}- Password Hashing: All passwords stored with PHP password_hash()
- SQL Injection Protection: Prepared statements throughout
- CSRF Protection: Session-based authentication
- Role-based Access: Admin/User permission levels
- Input Sanitization: All user input properly escaped
For production deployment:
- Upload
tracker.jsto your CDN - Update tracking snippets to use CDN URL
- Configure CORS headers if needed
- Consider caching strategies for optimal performance
- Create a test HTML file with tracking code
- Open in browser and verify data appears in admin panel
- Test different browsers and devices
- Verify statistics accuracy
Enable debug mode by adding to tracking code:
<script>window.BRICKMMO_DEBUG = true;</script>- Lightweight Tracking: Minimal JavaScript footprint
- Asynchronous Loading: Non-blocking script execution
- Database Indexing: Optimized queries for large datasets
- Efficient Queries: Pagination and filtering for large data sets
This project is part of the BrickMMO ecosystem. For contributions:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
This project is part of BrickMMO and follows the same licensing terms.
Tarun Shokeen
- Course: HTTP 5310 Capstone
- Professor: Adam Thomas (codeadamca)
- Institution: Humber College
- BrickMMO Parts v2 - Reference implementation
- BrickMMO CDN - Content delivery network
- BrickMMO Main Site - Official website
For technical support or questions:
- Create an issue in this repository
- Contact the development team through BrickMMO channels
- Refer to the BrickMMO documentation
Note: Remember to change default passwords and review security settings before deploying to production!