google analytics core api results sampling level -
i have script pulling data google analytics core api. since using results of data populate sheet in gsheets know data pull success.
i'm reading documentation here.
in particular, table:
however, logger.log() sampling level of query:
// check sampling each report if(!results.containssampleddata) { logger.log('sampling: none'); } else { logger.log('sampling: ' + results.query.samplinglevel); }
when view logs 'sampling: undefined'.
how sampling results results object?
here generates results object, though don;t think it's relavant (but may wrong):
// ga data core api function getreportdataforprofile(profile, len_results, start_num) { var startdate = getlastndays(30); // set date range here var enddate = getlastndays(0); var optargs = { 'dimensions': 'ga:dimension5, ga:dimension4', // comma separated list of dimensions. 'start-index': start_num, 'max-results': len_results, 'filters': 'ga:source==cj' }; // make request api. var results = analytics.data.ga.get( // mcf multi channel api, ga core profile, // table id (format ga:xxxxxx). startdate, // start-date (format yyyy-mm-dd). enddate, // end-date (format yyyy-mm-dd). 'ga:goalcompletionsall, ga:users, ga:sessions', // comma seperated list of metrics. optargs); return results; }
i think missed sentence:
the following table summarizes query parameters accepted core reporting api.
those query parameters. in other words, values supply. so, should know sampling level since determine it.
here's doc on sampling level. if not supplied, sets samplinglevel default.
edit: here's doc on response. see indeed includes samplinglevel field, if scroll further down, samplinglevel isn't 1 of fields described in response fields table. suspect either included in response accident or cannot rely upon field given lack of documentation.
Comments
Post a Comment