0
votes

This question is kind of a two-parter. I would appreciate it if I could get answers for both parts.

Part 1 - Wider date range shows less visits than narrower range

I am having trouble with a query of mine. These are the dimensions and metrics and filters I am using:

metrics: ga:visits,ga:visitBounceRate,ga:goalCompletionsAll,ga:goalConversionRateAll
dimensions: ga:landingPagePath,ga:medium
filters: ga:landingPagePath==/online-access/benefits-online-account-video.html;ga:visits>1;ga:medium==organic,ga:hasSocialSourceReferral==Yes,ga:medium==cpc,ga:medium==CPC

If start-date is 2015-01-01 and end-date is 2015-05-30, the query returns 0 for all fields, but if I change the start date to 2015-02-01 and the end date to 2015-02-28, I get 17 visits, and the other metric fields have values that look more correct. After investigating it a little bit, I thought maybe it had something to do with a dimensions-metric mismatch, but at this point I really have no idea.

Part 2 - Matching Dimensions and Metrics

I am a little confused about how you can combine metrics and dimensions. For example, the Dimensions and Query Explorer seems to suggest that ga:sessions can only be combined with ga:sessionDurationBucket or the deprecated ga:visitLength. But this sample code from the GA API reference shows ga:sessions combined with ga:source and ga:keyword - Neither of which are listed as compatible dimensions in the explorer.

Conclusion

Can someone make sense of this to me? I'm pretty new to Google Analytics in general, let alone accessing it through the API, so I may not have yet picked up the fundamentals needed to really understand what is happening here.

Edit: The reports in the actual Google Analytics interface say that it used 100 percent of sessions, so I believe that means it is not using sampled data. Also, the graphs show sessions up in the millions for the wider date range. And if I narrow the date range to just February, it shows 1,189,675 sessions~~, so 17 sessions is ridiculously wrong anyway.~~ I just realized this is not filtered for the specific page I'm filtering for in the query.

(I know I'm using some deprecated ga: values, but it really should work the same, no?)

1
Most important question: do your reports contain sampled data? - Philip Walton
And this is where my knowledge of Google Analytics begins to fail. Where do I check that? - Matt H
Figured it out. At the top of the report it says "This report is based on 1,206,437 sessions (100% of sessions)." So that would mean it does not use sampled data correct? - Matt H

1 Answers

0
votes

Part 1 -- you are likely running into a sampling issue. Although your edit says you are getting unsampled data, it is not clear if you are looking at the same report (and date range) as your query. Some reports are unsampled, but when you add custom filters, they tend to increase the probability that GA will sample. Try to rebuild the report in your GA user interface first, and determine if it's sampled or not. (Click on the Customization tab in this image.)

enter image description here

Part 2 -- I'm not sure where you are getting 'compatible' dimensions and metrics here. The real conflict in Google Analytics is whether you're filtering by users or by sessions. If you're using sessions, then you can extract any dimension (think x-axis on a chart) that gives information about a session: where it came from (i.e. source and medium), when it occurred (i.e. date), which session duration bucket it falls into. The dimension is the grouping parameter for your metric (think y-axis).

So in the sample code you linked:

Get apiQuery = analytics.data().ga()
.get(tableId,                  // Table Id.
    "2012-01-01",              // Start date.
    "2012-01-15",              // End date.
    "ga:sessions")               // Metrics.
.setDimensions("ga:source,ga:keyword")
.setSort("-ga:sessions,ga:source")
.setFilters("ga:medium==organic")
.setMaxResults(25);

This is going to pull the number of sessions (your metric) that occurred from 2012-01-01 to 2012-01-15, grouped by source and keyword (your dimensions), for the organic medium only, then sorted by sessions and source for readability. It's the same information that shows up in your Google Analytics -> Acquisition reporting menu, so it's kosher to query the API the same way.