dylankbuckley
dylankbuckley

Reputation: 1647

Google Analytics Query Explorer doesn't match api results

I have the following request:

     viewId: XXXXXX,
     dateRanges: [ { startDate: '7daysAgo', endDate: 'today' } ],
     metrics: [{expression: 'ga:sessions'}, {expression: 'ga:avgSessionDuration'}],
     dimensions: [{name: 'ga:date'}, {name: 'ga:country'}, {name: 'ga:source'}, {name: 'ga:countryIsoCode'}, {name: 'ga:pagePath'}],
     samplingLevel: 'LARGE'

When I run this query on the GA Query Explorer I get the data returned exactly how I want it.

When I do an API request, I am only returned the rows where sessions > 0.

I think the Query Explorer is still running V3 of the API. But am I missing something obvious?

Here is the response from the Query Explorer. The red section is what is returned when I do the exact same call via a Node Request:

enter image description here

Upvotes: 0

Views: 1049

Answers (1)

etemple1
etemple1

Reputation: 1788

After a little more research I found the following in the Google Analytics API v3 to v4 migration docs:

The v3 include-empty-rows parameter corresponds to the includeEmptyRows field in v4. The v3 parameter defaults to true, while in v4 the field defaults to false. If you do not have the value set in v3 you will need to set the value to true in v4.

Since the Query Explorer is using v3, this is why you see the discrepancy.

Upvotes: 3

Related Questions