setono / google-analytics-measurement-protocol
A library that eases the generation of measurement protocol payloads
Installs: 42 213
Dependents: 3
Suggesters: 0
Security: 0
Stars: 5
Watchers: 4
Forks: 3
Open Issues: 2
Requires
- php: >=7.4
- ext-json: *
- php-http/discovery: ^1.18
- psr/http-client: ^1.0
- psr/http-client-implementation: ^1
- psr/http-factory: ^1.0
- psr/http-factory-implementation: ^1
- psr/http-message: ^1.0 || ^2.0
- psr/log: ^1.0 || ^2.0 || ^3.0
- setono/google-analytics-events: ^1.0@rc
- symfony/polyfill-php80: ^1.27
Requires (Dev)
- infection/infection: ^0.26
- nyholm/psr7: ^1.8
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.6
- psalm/plugin-phpunit: ^0.18
- setono/code-quality-pack: ^2.4
- symfony/http-client: ^5.4 || ^6.0
- 2.x-dev
- v2.0.0-beta.2
- v2.0.0-beta
- v2.0.0-alpha.2
- v2.0.0-alpha
- 1.x-dev
- v1.0.0
- v1.0.0-alpha.8
- v1.0.0-alpha.7
- v1.0.0-alpha.6
- v1.0.0-alpha.5
- v1.0.0-alpha.4
- v1.0.0-alpha.3
- v1.0.0-alpha.2
- v1.0.0-alpha
- 0.4.x-dev
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.1
- v0.1.0
- dev-dependabot/composer/phpunit/phpunit-tw-10.5
- dev-dependabot/composer/infection/infection-tw-0.27
- dev-make-mutable
This package is auto-updated.
Last update: 2024-12-18 22:34:19 UTC
README
Easily build payloads for the Google Analytics measurement protocol.
Installation
composer require setono/google-analytics-measurement-protocol
Usage
<?php require_once '../vendor/autoload.php'; use Setono\GoogleAnalyticsEvents\Event\AddToCartEvent; use Setono\GoogleAnalyticsEvents\Event\Item\Item; use Setono\GoogleAnalyticsMeasurementProtocol\Client\Client; use Setono\GoogleAnalyticsMeasurementProtocol\Request\Body; use Setono\GoogleAnalyticsMeasurementProtocol\Request\Request; $client = new Client(); $request = (new Request( 'YOUR_SECRET', 'G-12341234', 'CLIENT_ID' )) ->addEvent( AddToCartEvent::create() ->setCurrency('USD') ->setValue(123.45) ->addItem(Item::create()->setId('SKU1234')->setName('Blue t-shirt')), ) ->setTimestamp(1668509674013800) ; $client->sendRequest($request);