PHPackages                             tda/laravel-analytics-v4 - 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. [API Development](/categories/api)
4. /
5. tda/laravel-analytics-v4

ActiveLibrary[API Development](/categories/api)

tda/laravel-analytics-v4
========================

GA4 integration for laravel 8

v1.0.0(3y ago)02.2kMITPHPPHP ^8.1

Since Mar 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/thedigitalarchitects/laravel-analytics-v4)[ Packagist](https://packagist.org/packages/tda/laravel-analytics-v4)[ Docs](https://github.com/thedigitalarchitects/laravel-analytics-v4)[ RSS](/packages/tda-laravel-analytics-v4/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (14)Versions (2)Used By (0)

GA4 integration for laravel 8
=============================

[](#ga4-integration-for-laravel-8)

This package offers integration to GA4 properties with some out of the box methods. Inspired by [Spatie integration](https://github.com/spatie/laravel-analytics) for GA3 and originally forked from MyOutDeskLLC. Requires Laravel 8+.

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

[](#installation)

You can install the package via composer:

```
composer require tda/laravel-analytics-v4
```

You can publish the config file with:

```
php artisan vendor:publish --tag="analytics-v4-config"
```

This is the contents of the published config file:

```
return [
    'property_id' => env('ANALYTICS_PROPERTY_ID', 'XXXXXXXXX'),
    'service_account_credentials_json' => storage_path('app/analytics/service-account-credentials.json'),
    // This data is passed into the built-in cache mechanism for google's CredentialWrapper
    'cache' => [
        'enableCaching' => env('ANALYTICS_CACHE',false),
        'authCache' => null,
        'authCacheOptions' => [
            'lifetime' => env('ANALYTICS_CACHE_LIFETIME', 60), // you may want to set this higher
            'prefix' => env('ANALYTICS_CACHE_PREFIX', 'analytics_'),
        ]
    ]
];
```

Usage
-----

[](#usage)

Inside Laravel:

```
use Tda\LaravelAnalyticsV4\Period;
use Tda\LaravelAnalyticsV4\PrebuiltRunConfigurations;

$client = App::make('laravel-analytics-v4');
$lastMonth = Period::months(1);
$results = $client->runReport(PrebuiltRunConfigurations::getMostVisitedPages($lastMonth));
```

You may configure your own report configuration, or use a pre-built report:

```
// Use this on the laravel side to get it from the container
$analytics = App::make('laravel-analytics-v4');

// Prepare a filter
$filter = new StringFilter();
$filter->setDimension('country')->exactlyMatches('United States');

// Prepare a report
$reportConfig = (new RunReportConfiguration())
                ->setStartDate('2022-09-01')
                ->setEndDate('2022-09-30')
                ->addDimensions(['country', 'landingPage', 'date'])
                ->addMetric('sessions')
                ->addFilter($filter);

$analytics->convertResponseToArray()->runReport($reportConfig);
```

Yay, results:

```
  [
    "dimensions" => [
      "country" => "United States",
      "landingPage" => "/",
      "date" => "20220903",
    ],
    "metrics" => [
      "sessions" => "113",
    ],
  ],
  [
    "dimensions" => [
      "country" => "United States",
      "landingPage" => "/services/",
      "date" => "20220902",
    ],
    "metrics" => [
      "sessions" => "110",
    ],
  ],

```

Or Using Prebuilt Report Configurations:

```
$lastMonth = Period::months(1);
$analytics->runReport(PrebuiltRunConfigurations::getMostVisitedPages($lastMonth));
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Submit a PR with passing tests.

Credits
-------

[](#credits)

- [JL](https://github.com/WalrusSoup)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1160d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ae273774a20c2eefc3335bbcdb95f7df8e7f6d76019b102f0303eaa619e07fc?d=identicon)[thedigitalarchitects](/maintainers/thedigitalarchitects)

---

Top Contributors

[![davileichs](https://avatars.githubusercontent.com/u/7110375?v=4)](https://github.com/davileichs "davileichs (5 commits)")

---

Tags

laravelga4laravel-analytics-v4tda

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.0k7.8M55](/packages/dedoc-scramble)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ryangjchandler/bearer

Minimalistic token-based authentication for Laravel API endpoints.

8129.8k](/packages/ryangjchandler-bearer)[combindma/laravel-facebook-pixel

Meta pixel integration for Laravel

4956.9k](/packages/combindma-laravel-facebook-pixel)[stechstudio/laravel-hubspot

A Laravel SDK for the HubSpot CRM Api

2971.0k](/packages/stechstudio-laravel-hubspot)[myoutdeskllc/laravel-analytics-v4

GA4 integration for laravel

153.9k](/packages/myoutdeskllc-laravel-analytics-v4)

PHPackages © 2026

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