Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cohort example ignores first cohort #16

Closed
borenstein opened this issue May 24, 2016 · 5 comments
Closed

Cohort example ignores first cohort #16

borenstein opened this issue May 24, 2016 · 5 comments

Comments

@borenstein
Copy link

Dear Mark,

First of all, thank you for writing this great R package! I am delighted to be able to use the API v4 directly from R.

I tried out the cohort example from the vignette, but it didn't behave the way I expected.

## first make a cohort group
cohort4 <- make_cohort_group(list("cohort 1" = c("2015-08-01", "2015-08-01"), 
                                "cohort 2" = c("2015-07-01","2015-07-01")))

## then call cohort report.  No date_range and must include metrics and dimensions
##   from the cohort list
cohort_example <- google_analytics_4(ga_id, 
                                     dimensions=c('cohort'), 
                                     cohort = cohort4, 
                                     metrics = c('cohortTotalUsers'))

This only returns a value for cohort 2. My first thought was that we didn't have data for cohort 1, but if I swapped the date ranges, I got only data for 2015-08-01. In fact, if I added a third row, I get the last two:

## first make a cohort group
cohort4 <- make_cohort_group(list("cohort 1" = c("2015-08-01", "2015-08-01"), 
                                "cohort 2" = c("2015-07-01","2015-07-01"),
                                "cohort 3" = c("2015-08-01", "2015-08-01")))

## then call cohort report.  No date_range and must include metrics and dimensions
##   from the cohort list
cohort_example <- google_analytics_4(ga_id, 
                                     dimensions=c('cohort'), 
                                     cohort = cohort4, 
                                     metrics = c('cohortTotalUsers'))

The above returns cohorts 2 and 3. Seems to be a simple off-by-one. I am using R 3.2.4 and I installed via install.packages today.

@borenstein
Copy link
Author

borenstein commented May 24, 2016

It appears that the return object is leaving off the first row of the results, but it's running the whole query. So consider the following example:

cohort4 <- make_cohort_group(list("August 2015" = c("2015-08-01", "2015-08-31"), 
                                  "July 2015" = c("2015-07-01","2015-07-31")))

## then call cohort report.  No date_range and must include metrics and dimensions
##   from the cohort list
cohort_example <- google_analytics_4(ga_id, 
                                     dimensions=c('cohort', "ga:cohortNthMonth"), 
                                     cohort = cohort4, 
                                     metrics = c('cohortTotalUsers', "ga:cohortRetentionRate"))

This returns a 7x4 table. The August 2015 cohort is missing the 0-month row. So that's where the issue lies.

@MarkEdmondson1234
Copy link
Collaborator

Thanks very much for this and detective work, definitely a bug that I will look to fix ASAP.

@MarkEdmondson1234
Copy link
Collaborator

MarkEdmondson1234 commented May 24, 2016

Well good news is that this is now fixed, bad news is that it was affecting all v4 calls, missing out the first row.

This was due to batching where I added the pageToken to the call, and in my R-brain I indexed it from 1, whereas it should have been from 0. I will submit this as a patch to the CRAN version ASAP.

Thanks very much for the report!

@borenstein
Copy link
Author

Thank you for developing the package!
On May 24, 2016 6:07 PM, "Mark" notifications@github.com wrote:

Well good news is that this is now fixed, bad news is that it was
affecting all v4 calls, missing out the first row. This was due to batching
add the pageToken and in my R-brain I indexed it from 1, whereas it should
have been from 0. I will submit this as a patch to the CRAN version ASAP.

Thanks very much for the report!


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/MarkEdmondson1234/googleAnalyticsR/issues/16#issuecomment-221416071

@MarkEdmondson1234
Copy link
Collaborator

MarkEdmondson1234 commented May 25, 2016

This is now on CRAN, version 0.1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants