PHP code example of reactmore / google-analytic-api-client
1. Go to this page and download the library: Download reactmore/google-analytic-api-client 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/ */
reactmore / google-analytic-api-client example snippets
composer
use Reactmore\GoogleAnalyticApi\Analytics;
use Reactmore\GoogleAnalyticApi\Helpers\Period;
// Auto Get from Dotenv
$Analytics = new Analytics();
// or manual
$Analytics = new Analytics([
'view_id' => 21312312313,
'service_credentials_json' => 'path/to/google_analytic_services.json'
]);
echo '<pre>';
var_dump($Analytics->Fetching()->fetchUserTypes(Period::days(7)));
echo '</pre>';
// Method
$Analytics = new Analytics();
// Fetch Users and New Users
$Analytics->Fetching()->fetchUserTypes(Period::days(7));
// Get Data Top Browser used visitor
$Analytics->Fetching()->fetchTopBrowsers(Period::days(7));
// Get Data Refferer Page
$Analytics->Fetching()->fetchTopReferrers(Period::days(7));
// Populer Pages
$Analytics->Fetching()->fetchMostVisitedPages(Period::days(7));
// Get Visitor and Pageviews
$Analytics->Fetching()->fetchTotalVisitorsAndPageViews(Period::days(7));