laravel-analytics

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

What is laravel-analytics?

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

Overview of laravel-analytics

What it is

laravel-analytics is a Laravel package that retrieves pageviews and other data from Google Analytics. It is developed by Spatie and requires PHP 8.4 or higher and Laravel 13. The package provides a fluent interface to query Google Analytics data and returns results as Illuminate Support Collection objects.

Key features

  • Retrieve most visited pages for a given period - Fetch visitors and page views by date or total - Get top referrers, browsers, countries, and operating systems - Support for user types (new vs returning)
  • Custom queries via a generic get method with metrics, dimensions, ordering, and filtering - Configurable caching of Google API responses (default 24 hours)

Use cases

  • Displaying analytics dashboards in Laravel applications - Generating reports on website traffic and user behavior - Integrating Google Analytics data into custom admin panels or automated reporting systems

Getting started

Install via Composer: bash composer require spatie/laravel-analytics Optionally publish the config file: bash php artisan vendor:publish --tag='analytics-config' Configure your Google Analytics property ID and service account credentials in the published config/analytics.php file or via environment variables. See the repository README for detailed instructions on obtaining credentials and granting permissions.

License and pricing

The package is open source under the MIT license. Pricing is not stated beyond being open source.

Based on the project's public README and repository metadata.

Add this badge to your README

Featured on YunoDB Badge styles & help

Maintain this project? Show that it is featured on YunoDB.

Markdown[![Featured on YunoDB](https://yunodb.com/badge/spatielaravel-analytics.svg)](https://yunodb.com/tools/spatielaravel-analytics?utm_source=github&utm_medium=badge)
HTML<a href="https://yunodb.com/tools/spatielaravel-analytics?utm_source=github&utm_medium=badge"><img src="https://yunodb.com/badge/spatielaravel-analytics.svg" alt="Featured on YunoDB" height="20"></a>