PHPackages                             redaelfillali/google-analytics-events - 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. redaelfillali/google-analytics-events

ActiveLibrary[API Development](/categories/api)

redaelfillali/google-analytics-events
=====================================

Send events to Google Analytics (GA4) via Measurement Protocol

1.1.0(3mo ago)0191PHPPHP ^8.1 || ^8.4

Since Jun 25Pushed 3mo agoCompare

[ Source](https://github.com/redafillali/google-analytics-events)[ Packagist](https://packagist.org/packages/redaelfillali/google-analytics-events)[ RSS](/packages/redaelfillali-google-analytics-events/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (2)Versions (6)Used By (0)

Google Analytics Events for Laravel
===================================

[](#google-analytics-events-for-laravel)

A lightweight Laravel package that sends events to **Google Analytics 4 (GA4)** using the **Measurement Protocol**.

> Track frontend or backend interactions (form submissions, purchases, clicks, etc.) directly from your Laravel app.

---

🚀 Features
----------

[](#-features)

- ✅ Simple API for sending custom GA4 events
- 🔐 Uses secure Measurement Protocol (`measurement_id` &amp; `api_secret`)
- 🍪 Automatically extracts `client_id` from `_ga` cookie or generates fallback UUID
- ⚙️ Configurable via `.env` or `config/google-analytics-events.php`

---

📦 Installation
--------------

[](#-installation)

### 1. Require the package

[](#1-require-the-package)

If installed locally (recommended for development):

```
composer require redaelfillali/google-analytics-events
```

Then install:

```
composer require redaelfillali/google-analytics-events
```

### 2. Publish the config

[](#2-publish-the-config)

```
php artisan vendor:publish --tag=config
```

### 3. Add your credentials to `.env`

[](#3-add-your-credentials-to-env)

```
GA_MEASUREMENT_ID=G-XXXXXXXXXX
GA_API_SECRET=your_secret_here
```

---

⚙️ Configuration
----------------

[](#️-configuration)

`config/google-analytics-events.php`:

```
return [
    'measurement_id' => env('GA_MEASUREMENT_ID', 'your-id'),
    'api_secret' => env('GA_API_SECRET', 'your-secret'),
];
```

---

📡 Usage
-------

[](#-usage)

### Send an event manually

[](#send-an-event-manually)

```
use Redaelfillali\GoogleAnalyticsEvents\GoogleAnalyticsService;

app(GoogleAnalyticsService::class)->sendEvent('form_submission', [
    'form_id' => 'contact',
    'submitted_at' => now()->toIso8601String(),
]);
```

### Optional: Provide a custom `client_id`

[](#optional-provide-a-custom-client_id)

```
app(GoogleAnalyticsService::class)->sendEvent('purchase', [
    'value' => 49.99,
], '123456789.987654321');
```

---

🧪 Debug
-------

[](#-debug)

Once events are sent correctly, visit your GA4 property:

**Google Analytics → Admin → DebugView**
To see real-time incoming events.

---

📁 Package Structure
-------------------

[](#-package-structure)

```
redaelfillali/google-analytics-events/
├── src/
│   ├── GoogleAnalyticsService.php
│   └── GoogleAnalyticsEventsServiceProvider.php
├── config/
│   └── google-analytics-events.php
├── composer.json
└── README.md

```

---

✅ Requirements
--------------

[](#-requirements)

- PHP 8.1+ or 8.4+
- Laravel 9, 10, 11, 12, or 13
- Google Analytics 4 property
- Measurement Protocol API secret

---

📃 License
---------

[](#-license)

MIT License

---

🤝 Credits
---------

[](#-credits)

Developed by [Reda El Fillali](https://www.linkedin.com/in/redaelfillali/)

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance82

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

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

Every ~70 days

Total

5

Last Release

92d ago

PHP version history (2 changes)v1.0.0PHP ^8.1

1.1.0PHP ^8.1 || ^8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/262098756?v=4)[REDA EL FILLALI](/maintainers/redaelfillali)[@redaelfillali](https://github.com/redaelfillali)

---

Top Contributors

[![redafillali](https://avatars.githubusercontent.com/u/20681013?v=4)](https://github.com/redafillali "redafillali (7 commits)")

### Embed Badge

![Health badge](/badges/redaelfillali-google-analytics-events/health.svg)

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

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.8k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[rapidez/core

Rapidez Core

1823.5k72](/packages/rapidez-core)

PHPackages © 2026

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