简体   繁体   中英

Data API PHP Client library Multiple Metrics

Can I request multiple Metrics using the Data API PHP client library?

ex) date for dimension , sessions and totalUsers for metric for Data API request

Sure why not? Metrics is just an array same as dimensions.

$response = $client->runReport([
    'property' => 'properties/' . $property_id,
    'dateRanges' => [
        new DateRange([
            'start_date' => '2020-03-31',
            'end_date' => 'today',
        ]),
    ],
    'dimensions' => [new Dimension(
        [
            'name' => 'date',
        ]
    ),
    ],
    'metrics' => [new Metric(
        [
            'name' => 'sessions',
        ]
    ),new Metric(
        [
            'name' => 'totalUsers',
        ]
    )
    ]
]);

API Quickstar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM