I am using Analytics Reporting v4 and Node.js.
I need to get a number of triggered events for a group of dimensions. For example:
- dimensions: date, source, medium, campaign
- metrics: pageviews, totalEvents
- where eventAction = "Test Action"
When I combine these two metrics: pageviews and totalEvents, it shows the wrong numbers in result. But when I use them separately, then it works well.
True results for metrics:
- total pageviews - 32 (but shows 17)
- total events - 9
Maybe someone knows why? Maybe because it does not calculate pageviews where the user didn't do an action ("Test Action")? And how can I do this correctly?
Response example - http://i.imgur.com/BUkqiQG.png
Request code:
reportRequests: [{
view_id: viewId,
dateRanges: [{
startDate: '2020-02-10',
endDate: '2020-02-10',
}],
dimensions: [
{
name: 'ga:date'
},
{
name: 'ga:source'
},
{
name: 'ga:medium'
},
{
name: 'ga:campaign'
}
],
metrics: [
{
expression: 'ga:pageviews'
},
{
expression: 'ga:totalEvents'
},
],
orderBys: [{
fieldName: 'ga:date',
sortOrder: "ASCENDING"
}],
dimensionFilterClauses: [{
filters: [
{
dimension_name: 'ga:eventAction',
operator: 'EXACT',
expressions: ["Test Action"]
}
]
}]
}]