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

ga_clientid_activity_unnest

Unnest user activity columns


Description

This helper function works with the output of user activity and parses out inner nested structure you may require.

Thanks to @jimmyg3g on GitHub for help with the ecommerce parsing.

Usage

ga_clientid_activity_unnest(
  hits,
  column = c("customDimension", "ecommerce", "goals")
)

Arguments

hits

The hits data.frame with the columns to expand

column

Which column to expand - one of "customDimension","ecommerce","goals"

Details

A function to help expand data out of nested columns returned by ga_clientid_activity

Value

An unnested data.frame tibble for all hits that matches the column

See Also

Examples

## Not run: 
# access clientIds for users who have transacted
viewId <- 106249469
date_range <- c("2019-01-01","2019-02-01")
cids <- google_analytics(viewId, 
                         date_range = date_range, 
                         metrics = "sessions", 
                         dimensions = "clientId", 
                         met_filters = filter_clause_ga4(
                           list(met_filter("transactions", 
                                           "GREATER_THAN", 
                                           0)
                                )))
                                
transactors <- ga_clientid_activity(cids$clientId,
                                    viewId = viewId, 
                                    date_range = date_range)

# unnest ecommerce activity hits from users
ga_clientid_activity_unnest(transactors$hits, "ecommerce")   

# unnest goal activity hits from users
ga_clientid_activity_unnest(transactors$hits, "goals") 

# unnest custom dimension activity hits from users
ga_clientid_activity_unnest(transactors$hits, "customDimension") 


## 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.