Analytics
2.7K members online now
2.7K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Data Different in Core Reporting API (using java) and Analytics dashboard

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

I am using Core reporting API through java to extract data with custom dimension. Refer Code below - 

DateRange dateRange = new DateRange();
dateRange.setStartDate("2016-08-01");
dateRange.setEndDate("2016-08-01");

Metric sessions = new Metric().setExpression("gaSmiley Tongueageviews").setAlias("PageViews");
Metric avgtime = new Metric().setExpression("ga:timeOnPage").setAlias("Time On Page");
List<Metric> list = new ArrayList<Metric>();
list.add(sessions);
list.add(avgtime);

Dimension dimension1 = new Dimension().setName("gaSmiley TongueagePath");
Dimension dimension2 = new Dimension().setName("ga:hostname");

List<Dimension> listd = new ArrayList<Dimension>();
listd.add(dimension1);
// listd.add(dimension2);

List<DimensionFilter> filterList = new ArrayList<DimensionFilter>();
DimensionFilter dimFilter = new DimensionFilter().setDimensionName("gaSmiley TongueagePath").setOperator("REGEXP")
.setExpressions(Arrays.asList("53474130"));
filterList.add(dimFilter);

DimensionFilterClause clause = new DimensionFilterClause().setFilters(filterList);
clause.setFilters(filterList);

List<GetReportsResponse> responseList = new ArrayList<GetReportsResponse>();
String pageToken = "";
while(pageToken != null){
ReportRequest request = new ReportRequest().setViewId(VIEW_ID).setDateRanges(Arrays.asList(dateRange))
.setDimensions(listd).setMetrics(list).setDimensionFilterClauses(Arrays.asList(clause));
System.out.println(request);
if(pageToken != null && !pageToken.isEmpty()){
request.setPageToken(pageToken); }
ArrayList<ReportRequest> requests = new ArrayList<ReportRequest>();
requests.add(request);

GetReportsRequest getReport = new GetReportsRequest().setReportRequests(requests);

GetReportsResponse response = service.reports().batchGet(getReport).execute();
System.out.println(response);
responseList.add(response);
pageToken = response.getReports().get(0).getNextPageToken();
break;
}

I am fetching data for two dimensions (pagePath and hostname). When ever I add "dimension2" [marked in red above] in query to core reporting API, Data comes out to be (3 records whose count is different from what I see on dashboard)- 

 

{
"dimensions": ["m.photos.timesofindia.com/celebs/celeb-themes/celebs-at-airport/articleshow/53474130.cms",
"m.photos.timesofindia.com"],
"metrics": [{
"values": ["12",
"19.0"]
}]
}{
"dimensions": ["m.photos.timesofindia.com/celebs/celeb-themes/celebs/celeb-themes/celebs-at-airport/articleshow/53474130.cms",
"m.photos.timesofindia.com"],
"metrics": [{
"values": ["231",
"698.0"]
}]
}{
"dimensions": ["photogallery.indiatimes.com/celebs/celeb-themes/celebs-at-airport/articleshow/53474130.cms",
"photogallery.indiatimes.com"],
"metrics": [{
"values": ["168",
"648.0"]
}]
}

 

But When i re-run my code without the "hostname" dimension, Data i see is conforming with what is visible on dashboard.

Please help me out here.

 

Regards,

Vibhav

1 Expert replyverified_user

Re: Data Different in Core Reporting API (using java) and Analytics dashboard

A T
Participant ✭ ✭ ✭
# 2
A T
Participant ✭ ✭ ✭
give it a try: https://ga-dev-tools.appspot.com/query-explorer/

Also in reports are you seeing any notification in yellow just above the graphs?

Re: Data Different in Core Reporting API (using java) and Analytics dashboard

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Hi A T,
Thanks a lot for your response.

Given link is of much help.

In the link above, I get the same result, i.e, with one dimension, I get Data that is similar to data on GA Dashboard. And on passing two dimensions, data is different,
I am new to GA and does not know much of the stuff.
Yes i am seeing a notification in yellow color above. It says -"This report includes a high-cardinality dimension, and some data has been grouped into (other)."

Kindly guide me further.

Re: Data Different in Core Reporting API (using java) and Analytics dashboard

Explorer ✭ ✭ ☆
# 4
Explorer ✭ ✭ ☆
Hi,

When you add more than one dimension in your report you will see only records that have data in all of them - if any CD will resolve to undefined then you won't see that entry in your report. For example: CD1 - "some data", CD2 - "undefined" will result in record not being shown in report because Google Analytics will not make a match of existing CD1 and non-existent CD2.

Hope that helped.

Re: Data Different in Core Reporting API (using java) and Analytics dashboard

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Hi,
How can I Verify that CD2 has some "undefined" value on GA Dashboard?

Re: Data Different in Core Reporting API (using java) and Analytics dashboard

Rising Star
# 6
Rising Star
Use the GA debugger tool (chrome extension) and the developer console, this will show you if the CDs are undefined or not.
John Wedderburn, Advertiser Community, Rising Star
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here.