3838use Google \Analytics \Data \V1beta \RunRealtimeReportResponse ;
3939
4040/**
41- * Runs a realtime report on a Google Analytics 4 property.
41+ * Runs a realtime report on a Google Analytics 4 property. Dimensions field is
42+ * omitted in the query, which results in total values of active users returned
43+ * for each minute range in the report.
44+ *
45+ * Note the `dateRange` dimension added to the report response automatically as
46+ * a result of querying multiple minute ranges.
4247 * @param string $propertyId Your GA-4 Property ID
4348 */
4449function run_realtime_report_with_minute_ranges (string $ propertyId )
@@ -67,7 +72,6 @@ function run_realtime_report_with_minute_ranges(string $propertyId)
6772 */
6873function printRunRealtimeReportWithMinuteRangesResponse (RunRealtimeReportResponse $ response )
6974{
70- // [START analyticsdata_print_run_realtime_report_response_header]
7175 printf ('%s rows received%s ' , $ response ->getRowCount (), PHP_EOL );
7276 foreach ($ response ->getDimensionHeaders () as $ dimensionHeader ) {
7377 printf ('Dimension header name: %s%s ' , $ dimensionHeader ->getName (), PHP_EOL );
@@ -80,10 +84,6 @@ function printRunRealtimeReportWithMinuteRangesResponse(RunRealtimeReportRespons
8084 PHP_EOL
8185 );
8286 }
83- // [END analyticsdata_print_run_realtime_report_response_header]
84-
85- // [START analyticsdata_print_run_realtime_report_response_rows]
86- print 'Report result: ' . PHP_EOL ;
8787
8888 foreach ($ response ->getRows () as $ row ) {
8989 printf (
@@ -92,7 +92,6 @@ function printRunRealtimeReportWithMinuteRangesResponse(RunRealtimeReportRespons
9292 $ row ->getMetricValues ()[0 ]->getValue ()
9393 );
9494 }
95- // [END analyticsdata_print_run_realtime_report_response_rows]
9695}
9796// [END analyticsdata_run_realtime_report_with_minute_ranges]
9897
0 commit comments