spatie/laravel-analytics
Laravel package to retrieve Google Analytics data in your app. Provides simple methods to fetch visitors, page views, and most visited pages over a given period, returning results as Laravel Collections via an easy-to-use facade.
Adopt if:
Look elsewhere if:
property_id).*"This package lets us tap into Google Analytics data without hiring a data engineer or building a custom API integration. For example, we can instantly answer questions like:
Analytics::fetchMostVisitedPages()Analytics::fetchTopReferrers()Analytics::fetchTopBrowsers()It’s secure (service account-based), cost-effective (caches responses), and scalable—all while reducing our backend team’s workload. We can use this to:
Risk: Minimal—it’s a battle-tested open-source package with 3,000+ stars. ROI: Days saved on development vs. months of custom work."*
*"This is a drop-in Laravel facade for GA4’s Data API. Key benefits:
Collection objects—integrates seamlessly with Eloquent, Blade, or queues.get() method with GA4’s API schema.Analytics::fake()).Trade-offs:
property_id per install (workaround: multiple Laravel instances or dynamic config).Example workflow:
// Get top 5 pages for the last 30 days
$topPages = Analytics::fetchMostVisitedPages(Period::days(30))
->take(5)
->pluck('pageTitle', 'screenPageViews');
// Use in a dashboard or alert system
if ($topPages->first()['screenPageViews'] < 1000) {
notify('Traffic alert: Top page views dropped!');
}
Setup time: ~1 hour (Google API setup + Laravel config). Maintenance: None—updates are handled via Composer."*
How can I help you explore Laravel packages today?