Skip to content

jorgemarcial/php-google-analytics-wrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

php-google-analytics-wrapper

Example of use code

$keyFileJson = 'service-account-credentials.json';

// Create and configure a new client object.
$report = new Report(
    array(
        'keyFileLocation' => $keyFileJson,
        'applicationName' => 'Example Analytics Reporting'
    )
);

// set date range with from and to dates.
$dateRange = $report->setDateRange('YYYY-MM-DD', 'YYYY-MM-DD');
// set metrics
$sessionsMetric = $report->setMetric("ga:sessions", "sessions");
// set dimensions
$operatingSystemDimension = $report->setDimension("ga:operatingSystem");

// generate reports object
$reports = $report->getReports(
    "VIEW_ID", 
    $dateRange,
    [$sessionsMetric],
    [$countryDimension]
);

// get array with results
$results = $report->getResults($reports);

About

Php google analytics wrapper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages