Analytics Core Reporting API. Rows in different segments have same values -
i have misconception, need understanding wrong.
at analytics.google.com have 2 segments differ event label both same event. in analytics interface difference between segments visible:
when i'm trying same data tool query explorer results different:
however, when i'm getting data reporting api v4, values same between segments. have tried api v3, resulted in similar outcomes.
here code:
googleapis.analyticsreporting('v4').reports.batchget({ 'headers': {'content-type': 'application/json'}, "auth": oauth2client, "resource":{ reportrequests:[ { "viewid": "ga:"+meteor.settings.admin.googleapi.viewid, "dateranges":[{ "startdate": '2016-07-01', "enddate": moment().format('yyyy-mm-dd'), }], "metrics": [{"expression":"ga:pageviews"},{"expression":"ga:avgtimeonpage"}], "dimensions": [{"name":"ga:pagepath"},{"name":"ga:segment"}], "segments": [{ "dynamicsegment": { "name": "version_bw", "usersegment": { "segmentfilters": [ { "simplesegment": { "orfiltersforsegment": [ { "segmentfilterclauses": [ { "dimensionfilter": { "dimensionname": "ga:eventaction", "operator": "exact", "expressions": ["set-visual-code"] } },{ "dimensionfilter": { "dimensionname": "ga:eventlabel", "operator": "exact", "expressions": ["bw"] } } ] }] } }] } } },{ "dynamicsegment": { "name": "version_color", "usersegment": { "segmentfilters": [ { "simplesegment": { "orfiltersforsegment": [ { "segmentfilterclauses": [ { "dimensionfilter": { "dimensionname": "ga:eventaction", "operator": "exact", "expressions": ["set-visual-code"] } },{ "dimensionfilter": { "dimensionname": "ga:eventlabel", "operator": "exact", "expressions": ["color"] } } ] }] } }] } } }] } ] } }, function(err, response) { if (err) { console.log('api error: '+ err); return; } var rows = response.reports[0].data.rows; (var = 0; < rows.length; i++) { console.log(rows[i].dimensions); console.log(rows[i].metrics); } });
which results in following output:
i20160719-14:09:10.405(2)? [ '/', 'version_bw' ] i20160719-14:09:10.406(2)? [ { values: [ '373', '174.11977715877438' ] } ] i20160719-14:09:10.406(2)? [ '/', 'version_color' ] i20160719-14:09:10.407(2)? [ { values: [ '373', '174.11977715877438' ] } ] i20160719-14:09:10.407(2)? [ '/portfolio', 'version_bw' ] i20160719-14:09:10.407(2)? [ { values: [ '468', '126.2876404494382' ] } ] i20160719-14:09:10.407(2)? [ '/portfolio', 'version_color' ] i20160719-14:09:10.408(2)? [ { values: [ '468', '126.2876404494382' ] } ] i20160719-14:09:10.408(2)? [ '/portfolio/', 'version_bw' ] i20160719-14:09:10.409(2)? [ { values: [ '22', '229.54545454545453' ] } ] i20160719-14:09:10.410(2)? [ '/portfolio/', 'version_color' ] i20160719-14:09:10.410(2)? [ { values: [ '22', '229.54545454545453' ] } ] i20160719-14:09:10.410(2)? [ '/portfolio/graphics', 'version_bw' ] i20160719-14:09:10.410(2)? [ { values: [ '84', '60.073170731707314' ] } ] i20160719-14:09:10.410(2)? [ '/portfolio/graphics', 'version_color' ] i20160719-14:09:10.410(2)? [ { values: [ '84', '60.073170731707314' ] } ] i20160719-14:09:10.411(2)? [ '/portfolio/graphics/some-graphic', 'version_bw' ] i20160719-14:09:10.411(2)? [ { values: [ '134', '42.02290076335878' ] } ] i20160719-14:09:10.411(2)? [ '/portfolio/graphics/some-graphic', 'version_color' ] i20160719-14:09:10.411(2)? [ { values: [ '134', '42.02290076335878' ] } ]
Comments
Post a Comment