PHPackages                             arcticfalcon/laravel-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. arcticfalcon/laravel-analytics

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

arcticfalcon/laravel-analytics
==============================

Analytics tracking for laravel 4.x

1.6(11y ago)066.9k1MITPHPPHP &gt;=5.4.0

Since Mar 7Pushed 11y ago1 watchersCompare

[ Source](https://github.com/arcticfalcon/laravel-analytics)[ Packagist](https://packagist.org/packages/arcticfalcon/laravel-analytics)[ RSS](/packages/arcticfalcon-laravel-analytics/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (2)Versions (13)Used By (0)

Analytics tracking package for Laravel 4.x
==========================================

[](#analytics-tracking-package-for-laravel-4x)

[![Latest Stable Version](https://camo.githubusercontent.com/0d0487f1a6b5aca2c730f6f29c2264691cab686cf77eb1e4f0301a71b6a3985f/68747470733a2f2f706f7365722e707567782e6f72672f61726374696366616c636f6e2f6c61726176656c2d616e616c79746963732f762f737461626c652e737667)](https://packagist.org/packages/arcticfalcon/laravel-analytics) [![Latest Unstable Version](https://camo.githubusercontent.com/57d27f4457e4905e55b26dc91c885ba87b00028948c8595fdb038c383d02cca1/68747470733a2f2f706f7365722e707567782e6f72672f61726374696366616c636f6e2f6c61726176656c2d616e616c79746963732f762f756e737461626c652e737667)](https://packagist.org/packages/arcticfalcon/laravel-analytics) [![License](https://camo.githubusercontent.com/7816a274481f4b6028373635177d6213a1ae3a114d568c999b3400a2f19f5149/68747470733a2f2f706f7365722e707567782e6f72672f61726374696366616c636f6e2f6c61726176656c2d616e616c79746963732f6c6963656e73652e737667)](https://packagist.org/packages/arcticfalcon/laravel-analytics) [![Total Downloads](https://camo.githubusercontent.com/9c5ccb2e6a36b291da1352ee85b54e5ba24f5391f5569514a544dccbad5e2353/68747470733a2f2f706f7365722e707567782e6f72672f61726374696366616c636f6e2f6c61726176656c2d616e616c79746963732f646f776e6c6f6164732e737667)](https://packagist.org/packages/arcticfalcon/laravel-analytics)

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

[](#installation)

Add to your composer.json following lines

```
"require": {
	"arcticfalcon/laravel-analytics": "~1.0"
}

```

Run `php artisan config:publish arcticfalcon/laravel-analytics`

Then edit `analytics.php` in `app/config/packages/arcticfalcon/laravel-analytics` to your needs.

Add `'ArcticFalcon\LaravelAnalytics\AnalyticsServiceProvider',` to `providers` in `app/config/app.php`.

Add `'Analytics' => 'ArcticFalcon\LaravelAnalytics\AnalyticsFacade',` to `aliases` in `app/config/app.php`.

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

[](#configuration)

```
provider	- Provider to use, possible Providers are: GoogleAnalytics, NoAnalytics

```

### Google Analytics

[](#google-analytics)

```
tracking_id	- Tracking ID

tracking_domain	- Tracking domain, unset or set to "auto" for automatic fallback

anonymize_ip - (true|false) anonymize users ip

auto_track - (true|false) auto tracking current pageview

```

Usage
-----

[](#usage)

In controller action (or anywhere else) use following statement to track an event or page view:

```
//	tracking the current page view
Analytics::trackPage();	// only necessary if `auto_track` is false or Analytics::disableAutoTracking() was called before

//	tracking an event
Analytics::trackEvent('category', 'action');

//	tracking a custom line
Analytics::trackCustom("ga('send', ......"); // this line will be added within the tracking script

```

In your view or layout template (e.g. a blade template) use the following statement:

```
{{ Analytics::render() }}

```

For Google Analytics you should place the statement right behind the `body` tag

```
{{ Analytics::render() }}

```

How to use
----------

[](#how-to-use)

The `GoogleAnalytics` Provider automatically controls the local environment behaviour for testing purposes. See  for details.

There is a builtin provider called `NoAnalytics`. This is for testing environments and tracks nothing. So you do not have to rewrite your code, simple select this `provider` in `analytics` configuration for your special environment configurations.

### Track a measurement without having javascript

[](#track-a-measurement-without-having-javascript)

1. Log in to Google Analytics and create custom definition. There you create a custom metrics. For example: Email opens, Integer type, min: 0 and max: 1 This will be available as `metric1`.
2. Within your mail template (or page template) you have to create a tracking image

    ``
3. That's it

API Documentation
-----------------

[](#api-documentation)

For the correct usage methods look at the `ArcticFalcon\LaravelAnalytics\Contracts\AnalyticsProviderInterface.php`

### Analytics::render()

[](#analyticsrender)

For rendering the correct javascript code.

```
/**
 * returns the javascript code for embedding the analytics stuff
 *
 * @return string
 */
public function render();

```

### Analytics::trackPage()

[](#analyticstrackpage)

For tracking a page view.

```
/**
 * track an page view
 *
 * @param null|string $page
 * @param null|string $title
 * @param null|string $hittype
 * @return void
 */
public function trackPage($page, $title, $hittype);

```

### Analytics::trackEvent()

[](#analyticstrackevent)

For tracking an event

```
/**
 * track an event
 *
 * @param string $category
 * @param string $action
 * @param null|string $label
 * @param null|int $value
 * @return void
 */
public function trackEvent($category, $action, $label, $value);

```

### Analytics::trackCustom()

[](#analyticstrackcustom)

For tracking a custom script line within the embedded analytics code.

```
/**
 * track any custom code
 *
 * @param string $customCode
 * @return void
 */
public function trackCustom($customCode);

```

### Analytics::enableAutoTracking()

[](#analyticsenableautotracking)

Enabling the auto tracking, overriding the configuration setting `auto_track`.

```
/**
 * enable auto tracking
 *
 * @return void
 */
public function enableAutoTracking();

```

### Analytics::disableAutoTracking()

[](#analyticsdisableautotracking)

Disabling the auto tracking, overriding the configuration setting `auto_track`.

```
/**
 * disable auto tracking
 *
 * @return void
 */
public function disableAutoTracking();

```

### Analytics::trackMeasurementUrl()

[](#analyticstrackmeasurementurl)

Sometimes you have to track measurements, e.g. opening an email newsletter. There you have no javascript at all.

```
/**
 * assembles an url for tracking measurement without javascript
 *
 * e.g. for tracking email open events within a newsletter
 *
 * @param string $metricName
 * @param mixed $metricValue
 * @param \ArcticFalcon\LaravelAnalytics\Data\Event $event
 * @param \ArcticFalcon\LaravelAnalytics\Data\Campaign $campaign
 * @param string|null $clientId
 * @param array $params
 * @return string
 */
public function trackMeasurementUrl($metricName, $metricValue, Event $event, Campaign $campaign, $clientId = null, array $params = array());

```

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

12

Last Release

4152d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.3.0

1.0.7PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c1a7a5723a3a63555e4bae89c135be7aaf7f7c80ced762f75b97140d2ac3190?d=identicon)[arcticfalcon](/maintainers/arcticfalcon)

---

Top Contributors

[![arcticfalcon](https://avatars.githubusercontent.com/u/7969215?v=4)](https://github.com/arcticfalcon "arcticfalcon (5 commits)")[![jfalcondb](https://avatars.githubusercontent.com/u/11094411?v=4)](https://github.com/jfalcondb "jfalcondb (5 commits)")[![rokde](https://avatars.githubusercontent.com/u/4946056?v=4)](https://github.com/rokde "rokde (3 commits)")[![justb81](https://avatars.githubusercontent.com/u/3680539?v=4)](https://github.com/justb81 "justb81 (2 commits)")

---

Tags

phplaraveljavascriptanalyticsstatisticsgoogle-analytics

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/arcticfalcon-laravel-analytics/health.svg)

```
[![Health](https://phpackages.com/badges/arcticfalcon-laravel-analytics/health.svg)](https://phpackages.com/packages/arcticfalcon-laravel-analytics)
```

###  Alternatives

[bezhansalleh/filament-google-analytics

Google Analytics integration for FilamentPHP

209175.5k8](/packages/bezhansalleh-filament-google-analytics)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[cornford/googlitics

An easy way to integrate Google Analytics with Laravel.

3210.2k](/packages/cornford-googlitics)

PHPackages © 2026

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