Skip to main content
Back to packages
3,238 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

Next.js Basics for Laravel Developers

11 lessons
58 min

Queues in Laravel 13

18 lessons
1 h 12 min read

How to Structure Laravel 13 Projects

16 lessons
1 h 32 min read