PHP code example of atlasmobile / yii2-ga

1. Go to this page and download the library: Download atlasmobile/yii2-ga 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/ */

    

atlasmobile / yii2-ga example snippets


return [
    ...
    'googleAnalytics' => [
        'developerKey' 		 => '', // Public key
        'clientId' 			 => 'xxx.apps.googleusercontent.com', // Client ID
        'analyticsId'        => 'ga:xxxxxxxxx', //(It is the number at the end of the URL starting with p: https://www.google.com/analytics/web/#home/a33443w112345pXXXXXXXX/)
        'serviceAccountName' => '[email protected]', // Email address
        'privateKeyPath'	 => '', //path to private key in p12 format
    ],
];


use atlasmobile\analytics\Analytics;

class Test
{
	public function example()
	{
		$analytics = new Analytics();
		$analytics->startDate = '';
		$analytics->endDate = '';
		
		$sessionsData = $analytics->getSessions();
		$visitorsData = $analytics->getUsers();
		$pageViewsData = $analytics->getPageViews();
		$avgSessionsDurationData = $analytics->getAvgSessionDuration();
		$countriesData = $analytics->getCountries();
	}
}


php composer.phar