NOTE: This repository is part of Google Cloud PHP. Any
support requests, bug reports, or development contributions should be directed to
that project.
Installation
To begin, install the preferred dependency manager for PHP, Composer.
Now install this component:
$ composer require google/analytics-data
This component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits offered by gRPC (such as streaming methods)
please see our gRPC installation guide.
Authentication
Please see our Authentication guide for more information
on authenticating your client. Once authenticated, you'll be ready to start making requests.
Sample
require 'vendor/autoload.php';
use Google\Analytics\Data\V1beta\Client\BetaAnalyticsDataClient;
use Google\Analytics\Data\V1beta\RunReportRequest;
$client = new BetaAnalyticsDataClient();
$request = new RunReportRequest([
'property' => 'properties/[YOUR_PROPERTY_ID]'
]);
$response = $client->runReport($request);
foreach ($response->getRows() as $row) {
foreach ($row->getDimensionValues() as $dimensionValue) {
print 'Dimension Value: ' . $dimensionValue->getValue() . PHP_EOL;
}
}
Debugging
Please see our Debugging guide
for more information about the debugging tools.
Version
This component is considered beta. As such, it should be expected to be mostly
stable and we're working towards a release candidate. We will address issues
and requests with a higher priority.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["Version latestkeyboard_arrow_down\n\n- [0.22.3 (latest)](/php/docs/reference/analytics-data/latest)\n- [0.22.2](/php/docs/reference/analytics-data/0.22.2)\n- [0.21.1](/php/docs/reference/analytics-data/0.21.1)\n- [0.20.1](/php/docs/reference/analytics-data/0.20.1)\n- [0.19.0](/php/docs/reference/analytics-data/0.19.0)\n- [0.18.0](/php/docs/reference/analytics-data/0.18.0)\n- [0.17.1](/php/docs/reference/analytics-data/0.17.1)\n- [0.16.4](/php/docs/reference/analytics-data/0.16.4)\n- [0.14.0](/php/docs/reference/analytics-data/0.14.0)\n- [0.13.0](/php/docs/reference/analytics-data/0.13.0)\n- [0.12.0](/php/docs/reference/analytics-data/0.12.0)\n- [0.11.2](/php/docs/reference/analytics-data/0.11.2)\n- [0.10.1](/php/docs/reference/analytics-data/0.10.1)\n- [0.9.5](/php/docs/reference/analytics-data/0.9.5) \n\nGoogle Analytics Data for PHP\n=============================\n\n| **Beta**\n|\n| This library is covered by the [Pre-GA Offerings Terms](/terms/service-terms#1) of the Terms of Service. Pre-GA libraries might have limited support, and changes to pre-GA libraries might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](/products#product-launch-stages).\n\u003e Idiomatic PHP client for [Google Analytics Data](https://analytics.google.com/analytics/web/provision/#/provision).\n\n[](https://packagist.org/packages/google/analytics-data) [](https://packagist.org/packages/google/analytics-data)\n\n**NOTE:** This repository is part of [Google Cloud PHP](https://github.com/googleapis/google-cloud-php). Any\nsupport requests, bug reports, or development contributions should be directed to\nthat project.\n\n### Installation\n\nTo begin, install the preferred dependency manager for PHP, [Composer](https://getcomposer.org/).\n\nNow install this component: \n\n $ composer require google/analytics-data\n\nThis component supports both REST over HTTP/1.1 and gRPC. In order to take advantage of the benefits offered by gRPC (such as streaming methods)\nplease see our [gRPC installation guide](https://cloud.google.com/php/grpc).\n\n### Authentication\n\nPlease see our [Authentication guide](https://github.com/googleapis/google-cloud-php/blob/main/AUTHENTICATION.md) for more information\non authenticating your client. Once authenticated, you'll be ready to start making requests.\n\n### Sample\n\n require 'vendor/autoload.php';\n\n use Google\\Analytics\\Data\\V1beta\\Client\\BetaAnalyticsDataClient;\n use Google\\Analytics\\Data\\V1beta\\RunReportRequest;\n\n $client = new BetaAnalyticsDataClient();\n\n $request = new RunReportRequest([\n 'property' =\u003e 'properties/[YOUR_PROPERTY_ID]'\n ]);\n $response = $client-\u003erunReport($request);\n\n foreach ($response-\u003egetRows() as $row) {\n foreach ($row-\u003egetDimensionValues() as $dimensionValue) {\n print 'Dimension Value: ' . $dimensionValue-\u003egetValue() . PHP_EOL;\n }\n }\n\n### Debugging\n\nPlease see our [Debugging guide](https://github.com/googleapis/google-cloud-php/blob/main/DEBUG.md)\nfor more information about the debugging tools.\n\n### Version\n\nThis component is considered beta. As such, it should be expected to be mostly\nstable and we're working towards a release candidate. We will address issues\nand requests with a higher priority.\n\n### Next Steps\n\n1. Understand the [official documentation](https://developers.google.com/analytics/devguides/reporting/data/v1)."]]