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

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

Recent Posts

Book: “Revenge of The Tipping Point”

June 10, 2025

Book: “Lord of Finance” – Thumbs Up

June 6, 2025

Big Changes – Japan, We’re Back!

February 26, 2025

  • GitHub
  • LinkedIn
  • Twitter

Blog under the Creative Commons Attribution 3.0 License
Creative Commons License