javascript - Organic Search Segment in Google Analaytics API for Apps Script -
i'm trying organic entrances single uri. filtered ga:pagepath==uri , tried use segment ga:organicsearches. segment doesn't seem work! following error: "invalid value 'ga:organicsearches' segment parameter" ideas on how fix this?
here funtion:
function getentrancesforuri(uri) { var enddate = '2016-01-26'; var startdate = '2015-12-28'; var profileid = xxxxxxxx; var tableid = 'ga:' + profileid; var optargs = { 'filters': 'ga:pagepath=='+uri, 'segment': 'ga:organicsearches' }; var result = analytics.data.ga.get( tableid, startdate, enddate, 'ga:entrances', optargs ); if (result) { return result; } else { return 0; } }
that not how construct segment. ga:organicsearches metric, , want segment dimension.
you can use dynamic segment described here this:
sessions::condition::ga:medium==organic
this segments out sessions have arrived via organic search.
alternatively can create segment in ga interface , find segment id via query explorer, , use in query. testing queries in query explorer idea in case, since instant feedback , useful error message.
Comments
Post a Comment