PHP code example of hametuha / gapiwp
1. Go to this page and download the library: Download hametuha/gapiwp 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/ */
hametuha / gapiwp example snippets
// Load auto loader.
y
\Hametuha\GapiWP\Loader::load();
// Get Google Analytics client.
$ga = \Hametuha\GapiWP\Loader::analytics();
// Get top 100 pave views of this year.
$result = $ga->fetch('2015-01-01', date_i18n('Y-m-d'), 'ga:pageviews', array(
'max-results' => 100,
'dimensions' => 'ga:pagePath',
'sort' => '-ga:pageviews'
));
// See what is retrieved.
var_dump($result);
exit;