PHPackages                             cornford/googlitics - 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. cornford/googlitics

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

cornford/googlitics
===================

An easy way to integrate Google Analytics with Laravel.

v3.0.0(6y ago)3310.2k4[1 PRs](https://github.com/bradcornford/Googlitics/pulls)MITPHPPHP &gt;=5.2CI failing

Since Aug 19Pushed 3y ago5 watchersCompare

[ Source](https://github.com/bradcornford/Googlitics)[ Packagist](https://packagist.org/packages/cornford/googlitics)[ RSS](/packages/cornford-googlitics/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (12)Used By (0)

An easy way to integrate Google Analytics with Laravel
======================================================

[](#an-easy-way-to-integrate-google-analytics-with-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/0c546058abfac8bd95c1a24d68ca6e5535660c9c02ac5b66a8f5700b70161fc5/68747470733a2f2f706f7365722e707567782e6f72672f636f726e666f72642f476f6f676c69746963732f76657273696f6e2e706e67)](https://packagist.org/packages/cornford/googlitics)[![Total Downloads](https://camo.githubusercontent.com/9995bf389e647bb3e9453718fd5668da93ee2136c2310a0d6c47d9c16a3486a7/68747470733a2f2f706f7365722e707567782e6f72672f636f726e666f72642f676f6f676c69746963732f642f746f74616c2e706e67)](https://packagist.org/packages/cornford/googlitics)[![Build Status](https://camo.githubusercontent.com/38a3cbf65ee1fb2c82799b514227c6d1da50b2a0b541ccd64139e60b269b6db9/68747470733a2f2f7472617669732d63692e6f72672f62726164636f726e666f72642f476f6f676c69746963732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/bradcornford/Googlitics)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3c84aa06ef9819e6ee3afa93778f427edb3226d3bb0ba3fe019680d04d982a48/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62726164636f726e666f72642f476f6f676c69746963732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bradcornford/Googlitics/?branch=master)

### For Laravel 5.x, check [version 2.5.0](https://github.com/bradcornford/Googlitics/tree/v2.5.0)

[](#for-laravel-5x-check-version-250)

### For Laravel 4.x, check [version 1.1.0](https://github.com/bradcornford/Googlitics/tree/v1.1.0)

[](#for-laravel-4x-check-version-110)

Think of Googlitics as an easy way to integrate Google Analytics with Laravel, providing a variety of helpers to speed up the utilisation of application tracking. These include:

- `Analytics::trackPage`
- `Analytics::trackScreen`
- `Analytics::trackEvent`
- `Analytics::trackTransaction`
- `Analytics::trackItem`
- `Analytics::trackMetric`
- `Analytics::trackException`
- `Analytics::trackCustom`
- `Analytics::render`

Installation
------------

[](#installation)

Begin by installing this package through Composer. Edit your project's `composer.json` file to require `cornford/googlitics`.

```
"require": {
	"cornford/googlitics": "3.*"
}

```

Next, update Composer from the Terminal:

```
composer update

```

Once this operation completes, the next step is to add the service provider. Open `app/config/app.php`, and add a new item to the providers array.

```
Cornford\Googlitics\AnalyticsServiceProvider::class,

```

The next step is to introduce the facade. Open `app/config/app.php`, and add a new item to the aliases array.

```
'Analytics'         => Cornford\Googlitics\Facades\AnalyticsFacade::class,

```

Finally we need to introduce the configuration files into your application/

```
php artisan vendor:publish --provider="Cornford\Googlitics\AnalyticsServiceProvider" --tag=googlitics

```

That's it! You're all set to go.

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

[](#configuration)

You can now configure Googlitics in a few simple steps. Open `app/config/packages/cornford/googlitics/config.php` and update the options as needed.

- `enabled` - Enable Google Analytics tracking.
- `id` A Google - Analytics tracking identifier to link Googlitics to Google Analytics.
- `domain` - The domain which is being tracked. Leave as 'auto' if you want Googlitics to automatically set the current domain. Otherwise enter your domain, e.g. google.com
- `anonymise` - Anonymise users IP addresses when tracking them via Googlitics.
- `automatic` - Enable automatic tracking to ensure users are tracked automatically by Googlitics.

Usage
-----

[](#usage)

It's really as simple as using the Analytics class in any Controller / Model / File you see fit with:

`Analytics::`

This will give you access to

- [Track Page](#track-page)
- [Track Screen](#track-screen)
- [Track Event](#track-event)
- [Track Transaction](#track-transaction)
- [Track Item](#track-item)
- [Track Metric](#track-metric)
- [Track Exception](#track-exception)
- [Track Custom](#track-custom)
- [Render](#render)

### Track Page

[](#track-page)

The `trackPage` method allows a page to be tracked, with optional parameters for page, title and track type.

```
Analytics::trackPage();
Analytics::trackPage('Homepage', 'Homepage Title');
Analytics::trackPage('Homepage', 'Homepage Title', Analytics::TYPE_PAGEVIEW);

```

### Track Screen

[](#track-screen)

The `trackScreen` method allows a screen in an application to be tracked, with a parameter for the screen name.

```
Analytics::trackScreen('Homepage');

```

### Track Event

[](#track-event)

The `trackEvent` method allows an event to be tracked, with parameters for category, and action option parameters for label and value.

```
Analytics::trackEvent();
Analytics::trackEvent('User', 'Sign up');
Analytics::trackEvent('User', 'Sign up', 'User - Sign up', date());

```

### Track Transaction

[](#track-transaction)

The `trackTransaction` method allows an ecommerce transaction to tracked, with parameters for identifier, and an optional options parameter for affiliation, revenue, shipping, tax in a key value array format.

```
Analytics::trackTransaction('123');
Analytics::trackTransaction('123', ['affiliation' => 'Clothing', 'revenue' => '12.99', 'shipping' => '7.99', 'tax' => '1.59']);

```

### Track Item

[](#track-item)

The `trackItem` method allows an ecommerce item to tracked, with parameters for identifier and name, and an optional options parameter for sku, category, price, quantity in a key value array format.

```
Analytics::trackItem('123', 'Socks');
Analytics::trackItem('123', 'Socks', ['sku' => 'PR123', 'category' => 'Clothing', 'price' => '7.99', 'quantity' => '1']);

```

### Track Metric

[](#track-metric)

The `trackMetric` method allows a metric to be tracked, with parameters for category, and an options parameter in a key value array format.

```
Analytics::trackMetric('Metric', ['metric1' => 100]);

```

### Track Exception

[](#track-exception)

The `trackException` method allows application exceptions to be tracked, with optional parameters for description and fatality.

```
Analytics::trackException();
Analytics::trackException('500 Server Error', true);

```

### Track Custom

[](#track-custom)

The `trackCustom` method allows custom items to be tracked with a single parameter for the custom item.

```
Analytics::trackCustom("ga('custom', 'parameter');");

```

### Render

[](#render)

The `render` method allows all tracking items to be rendered to the page, this method can be included in Views or added as controller passed parameter.

```
Analytics::render();

```

### License

[](#license)

Googlitics is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

Established project with proven stability

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 ~221 days

Recently: every ~266 days

Total

10

Last Release

2300d ago

Major Versions

v1.0.0 → v2.0.02015-06-17

v1.1.0 → v2.4.02019-11-12

v2.5.0 → v3.0.02020-01-30

PHP version history (2 changes)v1.0.0PHP &gt;=5.4.0

v3.0.0PHP &gt;=5.2

### Community

Maintainers

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

---

Tags

laravelgoogletrackinganalyticsstatistics

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cornford-googlitics/health.svg)

```
[![Health](https://phpackages.com/badges/cornford-googlitics/health.svg)](https://phpackages.com/packages/cornford-googlitics)
```

###  Alternatives

[spatie/laravel-analytics

A Laravel package to retrieve Google Analytics data.

3.2k5.7M57](/packages/spatie-laravel-analytics)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.8M7](/packages/wnx-laravel-stats)[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

205144.8k5](/packages/bezhansalleh-filament-google-analytics)[dragon-code/pretty-routes

Pretty Routes for Laravel

10058.7k4](/packages/dragon-code-pretty-routes)[bjuppa/laravel-blog

Add blog functionality to your Laravel project

483.3k2](/packages/bjuppa-laravel-blog)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

116.6k](/packages/tomshaw-electricgrid)

PHPackages © 2026

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