1. Go to this page and download the library: Download slm/google-analytics library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
slm / google-analytics example snippets
/**
* Web property ID (something like UA-xxxxx-x)
*/
'id' => '',
public function fooAction ()
{
$ga = $this->getServiceLocator()->get('google-analytics');
}
$ga->setEnableTracking(false);
$ga->setEnablePageTracking(false);
use SlmGoogleAnalytics\Analytics\Event;
$event = new Event('Videos', 'Play');
$ga->addEvent($event);
use SlmGoogleAnalytics\Analytics\Ecommerce\Transaction;
use SlmGoogleAnalytics\Analytics\Ecommerce\Item;
$transaction = new Transaction('1234', '28.28');
$item = new Item('5678', '11.99', '2', 'Blue elephant');
$transaction->addItem($item);
$ga->addTransaction($transaction);
/**
* Set the type of javascript to use for Google Analytics
*
* Allowed values: "google-analytics-ga" or "google-analytics-universal".
*/
'google_analytics' => array(
'script' => 'google-analytics-universal',
),