Download the PHP package guillaumevar/php-ga4-mp without Composer

On this page you can find all versions of the php package guillaumevar/php-ga4-mp. 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 php-ga4-mp

Google Analytics 4 Measurement Protocol PHP Library

Coverage Status Latest Stable Version Total Downloads

Overview

This is a PHP Library facilitating the use of Google Analytics 4 (GA4) Measurement Protocol. Measurement Protocol allows developers to send events directly from server-side PHP to Google Analytics.

Please note that GA4 Measurement Protocol is in alpha and might encounter breaking changes. Full documentation is available here: https://developers.google.com/analytics/devguides/collection/protocol/ga4

Requirements

dev:

Installation

The recommended way to install this library is via Composer (packagist package: br33f/php-ga4-mp).

Install by composer command:

or package.json

Usage

Send View Item Event

Send Purchase Event

At the moment, the library contains the defined structures of the following events: Event name Structure Documentation
add_payment_info AddPaymentInfoEvent see documentation
add_shipping_info AddShippingInfoEvent see documentation
add_to_cart AddToCartEvent see documentation
begin_checkout BeginCheckoutEvent see documentation
login LoginEvent see documentation
purchase PurchaseEvent see documentation
refund RefundEvent see documentation
remove_from_cart RemoveFromCartEvent see documentation
search SearchEvent see documentation
select_item SelectItemEvent see documentation
sign_up SignUpEvent see documentation
view_cart ViewCartEvent see documentation
view_item ViewItemEvent see documentation
view_search_results ViewSearchResultsEvent see documentation

These events are sent analogously to the examples presented above.

Other events

In order to send any event one can use BaseEvent structure and add any data. Please note that specific event structure should be used instead if already defined, since BaseEvent does not force any structure or provide data validation.

Debug event data and requests

Debuging event data is possible by sending them to debug endpoint (Measurement Protocol Validation Server), since default endpoint for Google Analytics 4 Measurement Protocol does not return any HTTP error codes or messages. In order to validate event one should use sendDebug($request) method instead of send($request).

Method sendDebug($request) returns DebugResponse object, which is hydrated with response data such as: status_code and validation_messages.

Example:

Unit Testing

Unit Testing for this module is done using PHPUnit 9.

Running unit tests:

License

This library is released under the MIT License.


All versions of php-ga4-mp with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1
guzzlehttp/guzzle Version ^7.0
ext-json Version *
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 guillaumevar/php-ga4-mp contains the following files

Loading the files please wait ....