PHP code example of krizon / php-ga-measurement-protocol

1. Go to this page and download the library: Download krizon/php-ga-measurement-protocol 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/ */

    

krizon / php-ga-measurement-protocol example snippets


$config = array(
    'ssl' => true // Enable/Disable SSL, default false
);
$client = Krizon\Google\Analytics\MeasurementProtocol\MeasurementProtocolClient::factory($config);
$client->pageview(array(
    'tid' => 'UA-XXXX-XXXX', // Tracking Id 
    'cid' => 'XXXX-XXXXX-XXXXX', // Customer Id
    'dh' => 'domain.do',
    'dp' => '/php-ga-measurement-protocol/phpunit-test',
    'dt' => 'PHP GA Measurement Protocol'
));