PHP code example of jmpatricio / easy-google-analytics
1. Go to this page and download the library: Download jmpatricio/easy-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/ */
jmpatricio / easy-google-analytics example snippets
$connector = new Jmpatricio\EasyGoogleAnalytics\Connector();
// Total visits for today
$totalVisitors = $connector->getTotalVisits();
// Total visits with from-to dates
$totalVisitors = $connector->getTotalVisits(new Carbon\Carbon('2015-08-01'), new Carbon\Carbon('2015-08-05'));
// Active users
$activeUsers = $connector->getActiveUsers();
// Generic API Access
// GA API
$fromDate = new Carbon\Carbon('2015-08-01');
$toDate = new Carbon\Carbon('2015-08-05');
$serviceResponse = $connector->getGA($fromDate,$toDate,'ga:visitors')
// Realtime API
$serviceResponse = $connector->getRT('rt:activeUsers',['dimensions'=>'rt:country']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.