Skip to main content
Back to packages
3,241 GitHub stars

spatie/laravel-analytics

View on GitHub

Description

A Laravel package to retrieve pageviews and other data from Google Analytics

Using this package you can easily retrieve data from Google Analytics.

Here are a few examples of the provided methods:

use Spatie\Analytics\Facades\Analytics;
use Spatie\Analytics\Period;
 
//fetch the most visited pages for today and the past week
Analytics::fetchMostVisitedPages(Period::days(7));
 
//fetch visitors and page views for the past week
Analytics::fetchVisitorsAndPageViews(Period::days(7));

Most methods will return an \Illuminate\Support\Collection object containing the results.

Recent Courses on Laravel Daily

Laravel 13 Starter Kit Teams and Customizations

10 lessons
33 min

Roles and Permissions in Laravel 13

14 lessons
57 min

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read