Download the PHP package baibaratsky/yii2-ga-measurement-protocol without Composer
On this page you can find all versions of the php package baibaratsky/yii2-ga-measurement-protocol. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download baibaratsky/yii2-ga-measurement-protocol
More information about baibaratsky/yii2-ga-measurement-protocol
Files in baibaratsky/yii2-ga-measurement-protocol
Package yii2-ga-measurement-protocol
Short Description Google Analytics Measurement Protocol for Yii2
License BSD-3-Clause
Homepage http://github.com/baibaratsky/yii2-ga-measurement-protocol
Informations about the package yii2-ga-measurement-protocol
Google Analytics Measurement Protocol for Yii2
Interact with Google Analytics directly. No need of any JS code. Pure server-side.
Full support for all methods of the Google Analytics Measurement Protocol is provided.
Installation
Note: Versions in 1. range are incompatible with PHP 7.2, use 2. with Yii 2.0.13+ instead.
-
The preferred way to install this extension is through composer.
To install, either run
or add
to the
require
section of yourcomposer.json
file.For PHP versions prior to 7.2, use a release from 1.* range:
- Add the component configuration in your
main.php
config file:
Usage
This extension is just a wrapper around the
Google Analytics Measurement Protocol library for PHP.
request()
returns a TheIconic\Tracking\GoogleAnalytics\Analytics
object, so all its methods will work seamlessly.
Basic Usage
Order Tracking with Enhanced E-commerce
Asynchronous Mode
By default, sending a hit to Google Analytics will be a synchronous request, and it will block the execution of the script until the latter gets a response from the server or terminates by timeout after 100 seconds (throwing a Guzzle exception). However, if you turn the asynchronous mode on in the component config, asynchronous non-blocking requests will be used.
This means that we are sending the request and not waiting for response.
The TheIconic\Tracking\GoogleAnalytics\AnalyticsResponse
object that you will get back has null
for HTTP status code.
You can also send an asynchronous request even if you haven’t turned it on in the config. Just call setAsyncRequest(true)
before sending the hit:
Auto set clientId from cookie
If you set autoSetClientId
to true
durning component configuration you must disable enableCookieValidation
.
You can do this by configuring request
component. Otherwise, the auto set clientId will not work.