Get more examples and tutorials at the googleAnalyticsR website
You also need googleAuthR
googleAuthR
install.packages("googleAuthR") install.packages("googleAnalyticsR")
remotes::install_github("MarkEdmondson1234/googleAnalyticsR")