Home > Blockchain >  How to check if my response contains sampled data
How to check if my response contains sampled data

Time:12-09

I am using Google.Apis.AnalyticsReporting.v4 to download a view between two days. I would like to know where in my response can I see whether the data contains sampled data?

This is the code for my request and we catch the data in response object below:

using (var analytics = new AnalyticsReportingService(new BaseClientService.Initializer { HttpClientInitializer = credential }))
{
    while (nextPageToken != null)
    {
        var reportRequest = new ReportRequest
        {
            ViewId = "123456",
            DateRanges = new[] { new DateRange { StartDate = "2021-06-01", EndDate = "2021-11-30" } },
            Dimensions = new List<Dimension>() {
                new Dimension { Name = "ga:transactionId" },
                new Dimension { Name = "ga:campaign" },
                new Dimension { Name = "ga:sourceMedium" }
            },
            Metrics = new[] { new Metric { Expression = "ga:users" }, new Metric { Expression = "ga:sessions" } },
                       
        };
        var requests = new List<ReportRequest>();
        requests.Add(reportRequest);
        // Create the GetReportsRequest object.
        var getReport = new GetReportsRequest() { ReportRequests = requests };

        // Call the batchGet method.
        var response = analytics.Reports.BatchGet(getReport).Execute();
    }
}

CodePudding user response:

It does not sample the data requested through Google.Apis.AnalyticsReporting.v4. However, if your query is too complex, it will return a 5xx error. Looks like it prevents its backend from executing queries for too long to avoid high loads. In that case, you'd need to chop your request into a few.

  • Related