Jose Uzcategui

Digital analytics, performance marketing and personal anecdotes.

  • Home
  • Blog
  • Contact

Powered by Genesis

Basic Script for R + Google Analytics

December 23, 2020 by Jose Uzcategui Leave a Comment

I get tired of wasting time searching for this in old files… I typically use BigQuery, but when it is handy, it is handy.

#install.packages("googleAnalyticsR")
library(googleAnalyticsR)
library(googleAuthR) 

ga_auth() #authorize googleAnalyticsR to access your data
my_accounts <- ga_account_list()
class(my_accounts)
is.data.frame(my_accounts)
dim(my_accounts)
my_accounts$accountName
 
arguments <- ga_meta()

my_id <- "362…." #my_id <- my_accounts$viewId[3]

dates <- c("2020-10-26","2020-10-26")
prodMetrics <- c("productListViews","productDetailViews","productAddsToCart", "productRemovesFromCart","cartToDetailRate","buyToDetailRate", "uniquePurchases","itemQuantity")

prodData <- google_analytics(my_id,
                                 date_range = dates,
                                 metrics = prodMetrics,
                                 dimensions = c("date","productName"))

Filed Under: Internet Marketing

Zen Space

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

Thoughts from a Nelson Mandela Biography

January 17, 2021

Thoughts on COVID-19 Coronavirus Pandemic

March 12, 2020

Thoughts On ‘Shoe Dog’, The Story of Nike’s Beginnings

November 10, 2019

  • GitHub
  • LinkedIn
  • Twitter

Blog under the Creative Commons Attribution 3.0 License
Creative Commons License