Download the PHP package bluepsyduck/ga4-measurement-protocol without Composer

On this page you can find all versions of the php package bluepsyduck/ga4-measurement-protocol. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package ga4-measurement-protocol

Google Analytics 4 Measurement Protocol Client

GitHub release (latest SemVer) build Codecov

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

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

Usage

This library uses PSR-17 and 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:

Pre-defined events

The library ships with classes representing the events as specified in the Google docs. These classes use public properties and type-hints to ensure basic data compatibility. The library does not contain any additional data validation to keep it as small as possible.

Here is an example of building an actual payload with pre-defined events:

All attributes of the events are considered optional by the library, and initialised with null. Please refer to the reference docs to get additional information about which attributes may actually be required to be set.

Custom events

To create your own events, simply implement the EventInterface and add the Event attribute to the class specifying the name of the event, as well as the Parameter attribute to each property which should get send to Google Analytics.

All parameters which should appear in the payload must be marked with the Parameter or ParameterArray attributes. It is recommended to make the default value of all parameters null, as those will get filtered out and do not appear in the payload.

Further reading


All versions of ga4-measurement-protocol with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bluepsyduck/ga4-measurement-protocol contains the following files

Loading the files please wait ....