Download the PHP package zfhassaan/genlytics without Composer
On this page you can find all versions of the php package zfhassaan/genlytics. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zfhassaan/genlytics
More information about zfhassaan/genlytics
Files in zfhassaan/genlytics
Package genlytics
Short Description Genlytics is a powerful Google Analytics Composer package that allows for easy data collection, analysis, and visualization. Optimized for SEO, it helps improve website performance and drive more organic traffic.
License MIT
Informations about the package genlytics
Disclaimer
The Google UA Property is going away from July 2023. Google is implementing the Google Analytics V4. Universal Analytics will no longer process new data in standard properties beginning on 1 July 2023. Prepare now by setting up and switching over to a Google Analytics 4 property. Learn More
The Google Analytics data will only be available through the GCP API.
About
Genlytics is a powerful Google Analytics 4 (GA4) package for Laravel, completely rewritten with Repository pattern, Event-driven architecture, and performance optimizations. The package integrates seamlessly with your Laravel application, providing intelligent caching, background job processing, and real-time analytics updates.
Key Features
- Repository Pattern - Abstracted data access layer for easy testing and extension
- Event-Driven - Decoupled event system for extensibility
- Intelligent Caching - Automatic cache management with configurable TTL (90%+ API call reduction)
- Background Jobs - Non-blocking analytics queries for better performance
- Real-Time Updates - Automatic refresh scheduling for live dashboards
- Type Safety - Full type hints and comprehensive PHPDoc
- Error Handling - Robust error handling with logging
- Comprehensive Tests - 52 test cases with 83+ assertions
- Backward Compatible - Existing code works without changes
Architecture Highlights
- Single Responsibility - Each class has one clear purpose
- Dependency Inversion - Dependencies on abstractions, not concretions
- Interface Segregation - Focused, specific interfaces
- Open/Closed - Extensible via interfaces without modification
Requirements
- PHP 8.1 or higher
- Laravel 9.0 or higher
- Google Analytics 4 (GA4) property
- Google Cloud Platform project with Analytics Data API enabled
- Service account with Analytics access
Installation
Install the package via Composer:
Auto-Discovery
The package supports Laravel's auto-discovery, so the service provider and facade will be automatically registered. No manual configuration needed!
Manual Registration (Optional)
If you prefer manual registration, add to config/app.php:
Configuration
Publish Configuration
Or publish everything:
Environment Variables
Add to your .env file:
Google Analytics Setup
- Create GA4 Property - Create a Google Analytics 4 property
- Enable Analytics Data API - Enable in Google Cloud Console
- Create Service Account - Create service account in GCP
- Generate JSON Key - Download service account JSON key
- Grant Analytics Access - Add service account email to GA4 property with Viewer/Analyst role
See Installation Guide for detailed steps.
Usage
Basic Usage
Or use the facade:
Or dependency injection:
Running Reports
Basic Report
Multiple Dimensions and Metrics
With Options
Force Refresh (Bypass Cache)
Real-Time Reports
Dimension Reports
Response Format
Advanced Features
Caching
Genlytics automatically caches analytics data to reduce API calls:
Benefits:
- 90%+ reduction in API calls
- Faster response times
- Lower API quota usage
Background Jobs
Process analytics queries in the background:
Benefits:
- Non-blocking requests
- Better user experience
- Automatic cache refresh
Real-Time Updates
Automatic real-time data refresh:
Events
Listen to analytics events:
Available Events:
AnalyticsDataRequested- Fired when data is requestedAnalyticsDataFetched- Fired when data is successfully fetchedAnalyticsCacheUpdated- Fired when cache is updatedAnalyticsQueryFailed- Fired when query fails
Using Repository Directly
For advanced usage, access the repository:
Publishing Test Cases
Publish test cases to your application for customization:
This publishes:
tests/Genlytics/TestCase.php- Base test casetests/Genlytics/Unit/- Unit teststests/Genlytics/Feature/- Feature teststests/Genlytics/Integration/- Integration tests
See PUBLISHING.md for details.
Testing
Run the test suite:
Or with coverage:
Test Coverage:
- 52 test cases
- 83+ assertions
- All major components tested
- Mocks for external dependencies (no real API calls needed)
Cache Management
Clear Cache
Refresh Specific Cache
Programmatic Cache Management
Common Use Cases
Dashboard Widget
Real-Time Visitor Count
Top Countries Report
Error Handling
Performance Optimizations
- Intelligent Caching - Reduces API calls by 90%+
- Background Processing - Non-blocking requests
- Query Optimization - Efficient parameter handling
- Real-Time Scheduling - Automatic refresh management
Documentation
- Installation Guide - Step-by-step setup
- Configuration Guide - All configuration options
- Usage Guide - Usage examples and best practices
- Troubleshooting - Common issues and solutions
- How to Release - Release process
- Contributing - Contribution guidelines
- Architecture - Architecture documentation
- Migration Guide - Migration from v1.x to v2.0
Changelog
See CHANGELOG.md for all changes.
v2.0.0 - Major Rewrite
- Complete rewrite with modern architecture
- Repository pattern implementation
- Event-driven architecture
- Intelligent caching system
- Background job processing
- Real-time updates
- Comprehensive test suite
- Enhanced error handling
- Full backward compatibility
Support
License
The MIT License (MIT). Please see License File for more information.
Author
- Author: Hassaan Ali
- Email: [email protected]
Made with ❤️ for the Laravel community
All versions of genlytics with dependencies
php Version ^8.1
google/analytics-data Version ^0.9.0
google/gax Version ^1.18
google/common-protos Version ^1.3.1||^2.0||^3.0
google/longrunning Version ^0.2
grpc/grpc Version ^1.13
google/protobuf Version ^3.21
google/cloud-core Version ^v1.48.1
google/grpc-gcp Version ^0.2.1
google/auth Version ^v1.24.0