Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pivot_ga4

Make a pivot object


Description

Make a pivot object

Usage

pivot_ga4(
  pivot_dim,
  metrics,
  dim_filter_clause = NULL,
  startGroup = 0,
  maxGroupCount = 5
)

Arguments

pivot_dim

A character vector of dimensions

metrics

Metrics to aggregate and return.

dim_filter_clause

Only data included in filter included.

startGroup

which groups of k columns are included in response (0 indexed).

maxGroupCount

Maximum number of groups to return.

Details

If maxGroupCount is set to -1 returns all groups.

Value

pivot object of class pivot_ga4 for use in filter_clause_ga4()

Examples

## Not run: 
library(googleAnalyticsR)

## authenticate, 
## or use the RStudio Addin "Google API Auth" with analytics scopes set
ga_auth()

## get your accounts
account_list <- google_analytics_account_list()

## pick a profile with data to query

ga_id <- account_list[23,'viewId']

## filter pivot results to 
pivot_dim_filter1 <- dim_filter("medium",
                                "REGEXP",
                                "organic|social|email|cpc")
                                
                                
pivot_dim_clause <- filter_clause_ga4(list(pivot_dim_filter1))

pivme <- pivot_ga4("medium",
                   metrics = c("sessions"), 
                   maxGroupCount = 4, 
                  dim_filter_clause = pivot_dim_clause)
                  
                  
pivtest <- google_analytics(ga_id, 
                            c("2016-01-30","2016-10-01"), 
                            dimensions=c('source'), 
                            metrics = c('sessions'), 
                            pivots = list(pivme))


## End(Not run)

googleAnalyticsR

Google Analytics API into R

v1.0.0
MIT + file LICENSE
Authors
Mark Edmondson [aut, cre] (<https://orcid.org/0000-0002-8434-3881>), Artem Klevtsov [ctb], Johann deBoer [ctb], David Watkins [ctb], Olivia Brode-Roger [ctb], Jas Sohi [ctb], Zoran Selinger [ctb], Octavian Corlade [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.