Download the PHP package theiconic/php-ga-measurement-protocol without Composer

On this page you can find all versions of the php package theiconic/php-ga-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 php-ga-measurement-protocol

Google Analytics Measurement Protocol library for PHP

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version Total Downloads License Documentation Status

Description

Send data to Google Analytics from the server using PHP. This library fully implements GA measurement protocol so its possible to send any data that you would usually do from analytics.js on the client side. You can send data regarding the following parameters categories (Full List):

Installation

Use Composer to install this package.

If you are using and then:

Or if you are using and then:

Take notice v1 is no longer maintained and lacks newer features (such as Debug and Hit validation), you are encourage to update to v2.

Integrations

You can use this package on its own, or use a convenient framework integration:

Feel free to create an integration with your favourite framework, let us know so we list it here.

Usage

The required parameters for all hits are Protocol Version, Tracking ID and at least one of these: Client ID or User ID. Some optional ones like IP Override are recommended if you don't want all hits to seem like coming from your servers.

The hit should have arrived to the GA property UA-26293728-11. You can verify this in your Real Time dashboard. Take notice, if you need GA reports to tie this event with previous user actions you must get and set the ClientId to be same as the GA Cookie. Read (here).

The library is 100% done, full documentation is a work in progress, but basically all parameters can be set the same way.

All methods for setting parameters should Autocomplete if you use an IDE such as PHPStorm, which makes building the Analytics object very easy.

Use Cases

Order Tracking with simple E-commerce

Order Tracking with Enhanced E-commerce

Batch Hits

GA has an endpoint that you can hit to register multiple hits at once, with a limit of 20 hits. Hits to be send can be placed in a queue as you build up the Analytics object.

Here's an example that sends two hits, and then empties the queue.

The queue is emptied when the hits are sent, but it can also be empty manually with emptyQueue method.

If more than 20 hits are attempted to be enqueue, the library will throw a EnqueueUrlsOverflowException.

Validating Hits

From Google Developer Guide:

The Google Analytics Measurement Protocol does not return HTTP error codes, even if a Measurement Protocol hit is malformed or missing required parameters. To ensure that your hits are correctly formatted and contain all required parameters, you can test them against the validation server before deploying them to production.

To send a validation hit, turn on debug mode like this

GA actually returns a JSON that is parsed into an associative array. Read (here) to understand how to interpret response.

Disable library hits for Staging/Dev environments

In your app configuration, you can have a flag for enabling or disabling the library, this in order to not actually send hits to GA, in this case the lib returns a AnalyticsResponseInterface object that returns empty values.

This is specially useful in dev or staging environments.

Contributors

License

THE ICONIC Google Analytics Measurement Protocol library for PHP is released under the MIT License.


All versions of php-ga-measurement-protocol with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
guzzlehttp/guzzle Version ^6.0 || ^7.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 theiconic/php-ga-measurement-protocol contains the following files

Loading the files please wait ....