Skip to content

Commit

Permalink
0-indexing breaking v4 first row fetch - fixes #16
Browse files Browse the repository at this point in the history
Gah, R is 1-index, but the API is 0-index.
  • Loading branch information
MarkEdmondson1234 committed May 24, 2016
1 parent ed0f4c7 commit a8bcd28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions R/ga_v4_get.R
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ google_analytics_4 <- function(viewId,
if(max > 10000){
## how many v4 batch requests can be made at one time (5-1) due to bad maths
batchLimit <- 5
meta_batch_start_index <- seq(from=1, to=max, by=10000*batchLimit)
meta_batch_start_index <- seq(from=0, to=max, by=10000*batchLimit)
batches <- length(meta_batch_start_index)

message("V4 Batching data into [", batches, "] calls.")
Expand Down Expand Up @@ -311,7 +311,7 @@ google_analytics_4 <- function(viewId,
segments=segments,
pivots=pivots,
cohorts=cohorts,
pageToken = 1,
pageToken = 0,
pageSize = max,
samplingLevel=samplingLevel,
metricFormat=metricFormat,
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ Details on [cohort reports and LTV can be found here](https://developers.google.

```r
## 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")))
cohort4 <- make_cohort_group(list("Jan2016" = c("2016-01-01", "2016-01-31"),
"Feb2016" = c("2016-02-01","2016-02-28")))

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

cohort_example
# cohort cohortTotalUsers
# 1 cohort 1 14
# 2 cohort 2 20
# cohort cohortTotalUsers
# 1 Feb2016 19040
# 2 Jan2016 23378

```

Expand Down

0 comments on commit a8bcd28

Please sign in to comment.