Skip to content

Instantly share code, notes, and snippets.

@ryanpraski
Last active December 22, 2016 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanpraski/8421e125f51278ba476d9f30a4510c49 to your computer and use it in GitHub Desktop.
Save ryanpraski/8421e125f51278ba476d9f30a4510c49 to your computer and use it in GitHub Desktop.
Google Analytics Reporting API v4 pivot table functionality example for googleAnalyticsR. This code is for Google Analtyics page scroll depth reporting. See the blog post here: http://www.ryanpraski.com/scroll-depth-tracking-analysis-with-google-analytics-r/
## filter pivot results
pivot_dim_filter1 <- dim_filter("eventLabel",
"REGEXP",
"%|#disqus")
pivot_dim_clause <- filter_clause_ga4(list(pivot_dim_filter1))
pivme <- pivot_ga4("eventLabel",
metrics = c("totalEvents"),
maxGroupCount = 5,
dim_filter_clause = pivot_dim_clause)
pivtest1 <- google_analytics_4(my_id,
c("2016-01-30","2016-12-20"),
metrics = c('totalEvents'),
dimensions = c('pagePath'),
filtersExpression = c("ga:eventLabel=~%|#disqus"),
anti_sample = TRUE,
pivots = list(pivme))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment