PHPackages                             setono/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. setono/google-analytics-events

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

setono/google-analytics-events
==============================

A library that eases the generation of Google Analytics events

v1.0.0-rc(2y ago)17.2k1MITPHPPHP &gt;=7.4

Since Aug 29Pushed 2y ago1 watchersCompare

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

READMEChangelog (4)Dependencies (6)Versions (5)Used By (0)

Google Analytics 4 (GA4) Events library
=======================================

[](#google-analytics-4-ga4-events-library)

[![Latest Version](https://camo.githubusercontent.com/09d70ec1315f87de4b8cc7ccc8da521a4ad87b989aabb4d7206745baebb5ed92/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f676f6f676c652d616e616c79746963732d6576656e74732f762f737461626c65)](https://packagist.org/packages/setono/google-analytics-events)[![Software License](https://camo.githubusercontent.com/c4d2edcc7bc4a9237f428787b8e4dc8bbb6eed5bb536cdba508b8e066b232277/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f676f6f676c652d616e616c79746963732d6576656e74732f6c6963656e7365)](LICENSE)[![Build Status](https://github.com/Setono/google-analytics-events/workflows/build/badge.svg)](https://github.com/Setono/google-analytics-events/actions)[![Code Coverage](https://camo.githubusercontent.com/408141257f5e27e84013b16ea54f4a4d2b966f3d2f830b2a1356cc41888673f1/68747470733a2f2f636f6465636f762e696f2f67682f5365746f6e6f2f676f6f676c652d616e616c79746963732d6576656e74732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Setono/google-analytics-events)[![Mutation testing](https://camo.githubusercontent.com/229ccd53c4313ae26f14bda5af8ccee71d823eb83bfbd7887f1a9f544cd11539/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532465365746f6e6f253246676f6f676c652d616e616c79746963732d6576656e74732532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/Setono/google-analytics-events/master)

Easily build [Google Analytics 4 Events](https://developers.google.com/analytics/devguides/collection/ga4/reference/events).

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

[](#installation)

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

Usage
-----

[](#usage)

```
use Setono\GoogleAnalyticsEvents\Event\PurchaseEvent;
use Setono\GoogleAnalyticsEvents\Writer\GtagWriter;

$event = PurchaseEvent::create('TRANS_1234')
    ->setCurrency('USD')
    ->setValue(123.45)
    ->setTax(10.45)
    ->setShipping(3.32)
    ->addItem(Item::create()->setId('SKU1234')->setName('Blue t-shirt'))
;

$writer = new GtagWriter();
echo $writer->write($event); // output: gtag("event", "purchase", {"currency":"USD","transaction_id":"TRANS_1234","value":123.45,"shipping":3.32,"tax":10.45,"items":[{"item_id":"SKU1234","item_name":"Blue t-shirt","quantity":1}]});
```

References
----------

[](#references)

-
-
-

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

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

Total

4

Last Release

979d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2412177?v=4)[Joachim Løvgaard](/maintainers/loevgaard)[@loevgaard](https://github.com/loevgaard)

---

Top Contributors

[![loevgaard](https://avatars.githubusercontent.com/u/2412177?v=4)](https://github.com/loevgaard "loevgaard (16 commits)")

---

Tags

analyticsga4googlegoogle-analyticsphp

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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