-
Requesting Data with Multiple Dimensions: pagePathPlusQueryString and deviceCategory
I’m trying to craft a request to snag page views for a specific URL, and I also need to pull in the device category and country id. However, I’ve hit a snag — when I send the request, I’m faced with the following error:
POST https://analyticsdata.googleapis.com:443/v1beta/properties/317256757:runReport?$alt=json;enum-encoding%3Dint
{
“error”: {
“code”: 400,
“message”: “Please remove pagePathPlusQueryString to make the request compatible. The request’s dimensions & metrics are incompatible. To learn more, see https://ga-dev-tools.web.app/ga4/dimensions-metrics-explorer/“,
“errors”: [
{
“message”: “Please remove pagePathPlusQueryString to make the request compatible. The request’s dimensions & metrics are incompatible. To learn more, see https://ga-dev-tools.web.app/ga4/dimensions-metrics-explorer/“,
“domain”: “global”,
“reason”: “badRequest”
}
],
“status”: “INVALID_ARGUMENT”
}I’m working with the Google Analytics Data API, GA4 version, and I’m writing my code in Java. Here’s the code for my request:
RunReportRequest request = RunReportRequest.newBuilder() .setProperty("properties/" + propertyID) .addMetrics(Metric.newBuilder().setName("screenPageViews")) .addDimensions(Dimension.newBuilder().setName("pagePathPlusQueryString")) .addDimensions(Dimension.newBuilder().setName("deviceCategory")) .addDimensions(Dimension.newBuilder().setName("countryId")) .addDateRanges(DateRange.newBuilder().setStartDate(startDate).setEndDate(endDate)) .build();
Log in to reply.