|
45 | 45 | $property_id = 'YOUR-GA4-PROPERTY-ID'; |
46 | 46 |
|
47 | 47 |
|
48 | | -// [START google_analytics_data_initialize] |
| 48 | +// [START analyticsdata_json_credentials_initialize] |
49 | 49 | /* TODO(developer): Replace this variable with a valid path to the |
50 | 50 | * credentials.json file for your service account downloaded from the |
51 | 51 | * Cloud Console. |
|
56 | 56 | // the private key file. |
57 | 57 | $client = new BetaAnalyticsDataClient(['credentials' => |
58 | 58 | $credentials_json_path]); |
59 | | -// [END google_analytics_data_initialize] |
| 59 | +// [END analyticsdata_json_credentials_initialize] |
60 | 60 |
|
61 | | -// [START google_analytics_data_run_report] |
| 61 | +// [START analyticsdata_json_credentials_run_report] |
62 | 62 | // Make an API call. |
63 | 63 | $response = $client->runReport([ |
64 | 64 | 'property' => 'properties/' . $property_id, |
|
79 | 79 | ]) |
80 | 80 | ] |
81 | 81 | ]); |
82 | | -// [END google_analytics_data_run_report] |
| 82 | +// [END analyticsdata_json_credentials_run_report] |
83 | 83 |
|
84 | | -// [START google_analytics_data_run_report_response] |
| 84 | +// [START analyticsdata_json_credentials_run_report_response] |
85 | 85 | // Print results of an API call. |
86 | 86 | print 'Report result: ' . PHP_EOL; |
87 | 87 |
|
88 | 88 | foreach ($response->getRows() as $row) { |
89 | 89 | print $row->getDimensionValues()[0]->getValue() |
90 | 90 | . ' ' . $row->getMetricValues()[0]->getValue() . PHP_EOL; |
91 | | -// [END google_analytics_data_run_report_response] |
| 91 | +// [END analyticsdata_json_credentials_run_report_response] |
92 | 92 | } |
93 | 93 |
|
94 | 94 | // [END analytics_data_quickstart] |
0 commit comments