PHPackages                             jmpatricio/easy-google-analytics - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jmpatricio/easy-google-analytics

ActivePackage[Utility &amp; Helpers](/categories/utility)

jmpatricio/easy-google-analytics
================================

1.0.4(10y ago)6772[1 issues](https://github.com/jmpatricio/easy-google-analytics/issues)MITPHPPHP &gt;=5.4.0

Since Aug 17Pushed 10y ago3 watchersCompare

[ Source](https://github.com/jmpatricio/easy-google-analytics)[ Packagist](https://packagist.org/packages/jmpatricio/easy-google-analytics)[ Docs](https://github.com/jmpatricio/easy-google-analytics)[ RSS](/packages/jmpatricio-easy-google-analytics/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (7)Used By (0)

Easy Google Analytics
=====================

[](#easy-google-analytics)

Laravel Package to connect Google Analytics
-------------------------------------------

[](#laravel-package-to-connect-google-analytics)

[![Latest Stable Version](https://camo.githubusercontent.com/8e4675f44f3d7f9913a2eecf3839b6246e108c1c55a83c3a04ab36b5862c6ec0/68747470733a2f2f706f7365722e707567782e6f72672f6a6d706174726963696f2f656173792d676f6f676c652d616e616c79746963732f762f737461626c65)](https://packagist.org/packages/jmpatricio/easy-google-analytics)[![Codacy Badge](https://camo.githubusercontent.com/dc6cd3903b40a8af9c59b25e05ec3dc9a15bbf61af9056b60e8fa889f783c6c6/68747470733a2f2f7777772e636f646163792e636f6d2f70726f6a6563742f62616467652f3630343061333465616639303436346262363439323065646565336135336464)](https://www.codacy.com/app/jmpatricio/easy-google-analytics)[![Code Climate](https://camo.githubusercontent.com/1926edfca6330e57af1e1b92498185549b207fda1cc4cc11edca26cd79ba3525/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6a6d706174726963696f2f656173792d676f6f676c652d616e616c79746963732f6261646765732f6770612e737667)](https://codeclimate.com/github/jmpatricio/easy-google-analytics)[![License](https://camo.githubusercontent.com/fcb3443dbfc6f985662502d937e0891b7122745a07550cbfed6b35f0cae4979e/68747470733a2f2f706f7365722e707567782e6f72672f6a6d706174726963696f2f656173792d676f6f676c652d616e616c79746963732f6c6963656e7365)](https://packagist.org/packages/jmpatricio/easy-google-analytics)

Changelog
---------

[](#changelog)

- 1.0.4 | 2015-08-21
- Added new users metric
- Duplicate code removed
- PHP Docs improved
- Code Style fixed

Instalation
-----------

[](#instalation)

1. Run `composer require jmpatricio/easy-google-analytics`
2. Add `Jmpatricio\EasyGoogleAnalytics\EasyGoogleAnalyticsServiceProvider` to your service providers
3. Instalation Done.

Configuration
-------------

[](#configuration)

This step is the most important. Let's make it simple:

- Open a terminal and run: `php artisan config:publish "jmpatricio/easy-google-analytics"`.
- Now you have `{$projectRoot}/app/config/packages/jmpatricio/easy-google-analytics/config.php` file with:

```
return [
    'client_id'            => 'xxx.apps.googleusercontent.com',
    'service_account_name' => 'xxx@developer.gserviceaccount.com',
    'keyfile'              => storage_path('xxx.p12'),
    'analytics_id'         => 'ga:xxx',
];
```

- Now you have to go to your googe developer account and configure a new project. (If you already have a project, ignore this step) [![Create a new project](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/configure_project.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/configure_project.png)
- You need to enable the Analytics API to your project. Inside project, go to APIs &amp; auth and then inside APIs. Enable the analytics
- Inside the project, on developers console, go to Credentials inside APIs &amp; auth, create a new Service Account [![](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/add_service_account_001.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/add_service_account_001.png)
- Choose a p12 key [![](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/add_service_account_002.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/add_service_account_002.png)
- Save your p12 key inside `{$projectRoot}/app/storage`.

[![](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/add_service_account_003.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/add_service_account_003.png)

- Edit the config file and define the keyfile entry: `'keyfile'              => storage_path('Easy-Google-Analytics-da31194a03c6.p12'),`
- Now you have the information about the credentials [![](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/client_data_001.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/client_data_001.png)Click on the email, and the following screen shows up: [![](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/client_data_002.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/client_data_002.png)
- Add the client id and the email address to the config:

```
return [
	'client_id'            => '459875649264-vs034lhn7ocddcch0nq1vdurst1mr8bu.apps.googleusercontent.com',
	'service_account_name' => '459875649264-vs034lhn7ocddcch0nq1vdurst1mr8bu@developer.gserviceaccount.com',
	'keyfile'              => storage_path('Easy-Google-Analytics-da31194a03c6.p12'),
	'analytics_id'         => 'ga:xxx',
];
```

- Now the only thing missing is the analytics id
- Go to your analytics dashboard, and inside the admin area select the view settings: [![](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/admin_analytics_001.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/admin_analytics_001.png)
- Copy the view id and add to the config: [![](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/admin_analytics_002.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/admin_analytics_002.png)

The config will be the following:

```
return [
    'client_id'            => '459875649264-vs034lhn7ocddcch0nq1vdurst1mr8bu.apps.googleusercontent.com',
    'service_account_name' => '459875649264-vs034lhn7ocddcch0nq1vdurst1mr8bu@developer.gserviceaccount.com',
    'keyfile'              => storage_path('Easy-Google-Analytics-da31194a03c6.p12'),
    'analytics_id'         => 'ga:106917230',
];
```

- Now we have to add permissions to the service account inside analytics console:
- Go to the analytics admin console, and add the user with the respective permissions: [![](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/service_account_permissions_001.png)](https://raw.githubusercontent.com/jmpatricio/easy-google-analytics-files/master/service_account_permissions_001.png)
- The configuration is complete!

Basic usage
-----------

[](#basic-usage)

```
$connector = new Jmpatricio\EasyGoogleAnalytics\Connector();

// Total visits for today
$totalVisitors = $connector->getTotalVisits();

// Total visits with from-to dates
$totalVisitors = $connector->getTotalVisits(new Carbon\Carbon('2015-08-01'), new Carbon\Carbon('2015-08-05'));

// Active users
$activeUsers = $connector->getActiveUsers();

// Generic API Access

// GA API
$fromDate = new Carbon\Carbon('2015-08-01');
$toDate = new Carbon\Carbon('2015-08-05');
$serviceResponse = $connector->getGA($fromDate,$toDate,'ga:visitors')

// Realtime API
$serviceResponse = $connector->getRT('rt:activeUsers',['dimensions'=>'rt:country']);
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

3923d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cef0df3505a8a3511b8e4695fb6febd6b0927a62641f6a138d853d1d57a07f64?d=identicon)[jmpatricio](/maintainers/jmpatricio)

---

Top Contributors

[![jmpatricio](https://avatars.githubusercontent.com/u/532073?v=4)](https://github.com/jmpatricio "jmpatricio (29 commits)")

---

Tags

laravelgoogleanalytics

### Embed Badge

![Health badge](/badges/jmpatricio-easy-google-analytics/health.svg)

```
[![Health](https://phpackages.com/badges/jmpatricio-easy-google-analytics/health.svg)](https://phpackages.com/packages/jmpatricio-easy-google-analytics)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[erlandmuchasaj/laravel-gzip

Gzip your responses.

40129.3k2](/packages/erlandmuchasaj-laravel-gzip)[cornford/googlitics

An easy way to integrate Google Analytics with Laravel.

3310.2k](/packages/cornford-googlitics)[panakour/analytics

Get whatever data you want from google analytics.

267.6k](/packages/panakour-analytics)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
