'Why is direct traffic not being returned from google analytics api?
I'm writing an application downloading data from Google Analytics in .NET core 3.5 using Google.Apis.AnalyticsReporting.v4. For some reason direct traffic (rows where sourceMedium is (direct) / (none) ) is not being returned from GA. No filters are applied and the date range is always one day. Playing around with it I found out that adding time dimension dateHour solves the issue. But it multiplies the number of rows significantly and I really want to avoid that.
Any idea why this request returns all records successfully:
ReportRequest reportRequest = new ReportRequest
{
ViewId = viewId,
//IncludeEmptyRows = true,
DateRanges = new List<DateRange>() { dateRange },
Metrics = new List<Metric>() { sessions, transactions, transactionRevenue },
Dimensions = new List<Dimension>() { date, sourceMedium, campaign, datehour },
//DimensionFilterClauses = new List<DimensionFilterClause>() { dimFilters },
PageSize = 10000,
PageToken = "1"
};
but when deleting the datehour dimension direct traffic (and only direct traffic) is missing from the response?
ReportRequest reportRequest = new ReportRequest
{
ViewId = viewId,
//IncludeEmptyRows = true,
DateRanges = new List<DateRange>() { dateRange },
Metrics = new List<Metric>() { sessions, transactions, transactionRevenue },
Dimensions = new List<Dimension>() { date, sourceMedium, campaign },
//DimensionFilterClauses = new List<DimensionFilterClause>() { dimFilters },
PageSize = 10000,
PageToken = "1"
};
IncludeEmptyRows parameter doesn't have any impact on the outcome. Any suggestions are welcomed.
Solution 1:[1]
The solution for me was to change the date range. When the StartDate and the EndDate are the same day all the traffic is returned except for direct traffic. When StartDate and the EndDate are not the same day all traffic gets returned.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ddeiml |
