PHPackages                             bluepsyduck/ga4-measurement-protocol - 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. bluepsyduck/ga4-measurement-protocol

ActiveLibrary[API Development](/categories/api)

bluepsyduck/ga4-measurement-protocol
====================================

A small client implementing the Measurement Protocol for Google Analytics 4.

2.0.0(4y ago)814.4k↓73.8%[1 issues](https://github.com/BluePsyduck/ga4-measurement-protocol/issues)1GPL-3.0-or-laterPHPPHP ^8.0

Since Sep 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/BluePsyduck/ga4-measurement-protocol)[ Packagist](https://packagist.org/packages/bluepsyduck/ga4-measurement-protocol)[ Docs](https://github.com/BluePsyduck/ga4-measurement-protocol)[ RSS](/packages/bluepsyduck-ga4-measurement-protocol/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (9)Versions (3)Used By (1)

Google Analytics 4 Measurement Protocol Client
==============================================

[](#google-analytics-4-measurement-protocol-client)

[![GitHub release (latest SemVer)](https://camo.githubusercontent.com/60f5a8af2b8380c5029ca0c6f20c6288715ad8a3881c77b0507bf4c0bf4ed51b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f426c75655073796475636b2f6761342d6d6561737572656d656e742d70726f746f636f6c)](https://github.com/BluePsyduck/ga4-measurement-protocol/releases)[![GitHub](https://camo.githubusercontent.com/55c0eb63a9afa858237c0d2ea14e93dc64acd6a1a676fe0e59fbeee12bb34f80/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f426c75655073796475636b2f6761342d6d6561737572656d656e742d70726f746f636f6c)](LICENSE.md)[![build](https://camo.githubusercontent.com/0cbadacd21df8ac1c62b1b4148a4376e8324f24113ab53d9f6427af59509ec49/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f426c75655073796475636b2f6761342d6d6561737572656d656e742d70726f746f636f6c2f43493f6c6f676f3d676974687562)](https://github.com/BluePsyduck/ga4-measurement-protocol/actions)[![Codecov](https://camo.githubusercontent.com/5a0b39f8a4cfed66271c2d363c7a2669059c65302e9df4c6ca1cd1e96b2a099e/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f426c75655073796475636b2f6761342d6d6561737572656d656e742d70726f746f636f6c3f6c6f676f3d636f6465636f76)](https://codecov.io/gh/BluePsyduck/ga4-measurement-protocol)

This library contains a small client able to send events through the Measurement Protocol to Google Analytics 4.

Please always keep Google's warning about the current state of the API in mind when using this library:

> **Warning:** This is an alpha API and subject to change. You may encounter breaking changes while it is in alpha. Code using this API should not be pushed to production. See limitations for issues that will be address before a general availability launch.

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

[](#installation)

Install this library through composer as any sane PHP developer would do:

```
composer require bluepsyduck/ga4-measurement-protocol
```

Usage
-----

[](#usage)

This library uses [PSR-17](https://www.php-fig.org/psr/psr-17/) and [PSR-18](https://www.php-fig.org/psr/psr-18/) to decouple its own logic from the actual client implementation. A compatible implementation must be provided to be able to use this library.

The following example shows how to use the `guzzlehttp/guzzle` package with the client class:

```
