google analytics data mining with r
TRANSCRIPT
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 1 #tatvicwebinar1/28/2015 1 #tatvicwebinar
Google Analytics Data Mining with R
(includes 3 Real Applications)
Jan 28th, 2015FREE Webinar by
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 2 #tatvicwebinar1/28/2015 2 #tatvicwebinar
Our Speakers
Kushan Shah
Maintainer of RGoogleAnalytics
Library & Web Analyst at Tatvic
@ kushan_s
Andy GranowitzDeveloper Advocate, Google
Analytics (Google)
@ agrano
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 3 #tatvicwebinar
Outline
An Introduction to R
Why analyze Google Analytics data with R
Getting started with R & Google Analytics
Questions & Answers
3 Real Life Applications & Use Cases
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 4 #tatvicwebinar
An Introduction to R
• Open source statistical computing language, widely used byorganizations to solve business problems
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 5 #tatvicwebinar
An Introduction to R
• Open source statistical computing language, widely used byorganizations to solve business problems
Data Analysis Statistical Tests
Data Visualization
Predictive Models
Forecasting
R
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 6 #tatvicwebinar
Why Use R
Easy to integrate with various data sources
Data Frame – Analogous to Excel Spreadsheet or MySQL Table
6000 Pre developed packages for various applications
No software licensing costs
Enables reproducible analysis
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 7 #tatvicwebinar
Outline of this Webinar
An Introduction to R
Why analyze Google Analytics data with R
Getting started with R & Google Analytics
Questions & Answers
3 Real Life Applications & Use Cases
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 8 #tatvicwebinar
Why analyze Google Analytics data with R
● Google Analytics API allows data extraction for custom reports
• Reports with up to 7 Dimensions and 10 Metrics
• API is well suited for batch data extraction
• API has techniques for handling large queries (10K - 1M records and beyond)
● RGoogleAnalytics = R Wrapper over the Google Analytics API
• Provides functions to easily interact with the Google Analytics API
• Takes care of the low level plumbing
● Google Analytics Premium User and data exported to Big Query
• Use the bigrquery package by Prof. Hadley Wickham
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 9 #tatvicwebinar
Outline of this Webinar
An Introduction to R
Why analyze Google Analytics data with R
Getting started with R & Google Analytics
Questions & Answers
3 Real Life Applications & Use Cases
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 10 #tatvicwebinar
Getting Started with R and Google Analytics
● Install R - http://www.r-project.org/
● Install RStudio - GUI for R (Optional)
● Install RGoogleAnalytics
Check out the blogpost for a step by step walkthrough - bit.ly/18oJjqA
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 11 #tatvicwebinar
Getting Started with R and Google Analytics
One Time Setup
● Create a Project in the Google Dev Console● Activate the Google Analytics API for your project● Get your Project’s Client ID and Client Secret
https://developers.google.com/analytics/devguides/reporting/core/v3/gdataAuthorization
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 12 #tatvicwebinar
Outline of this Webinar
An Introduction to R
Why analyze Google Analytics data with R
Getting started with R & Google Analytics
Questions & Answers
3 Real Life Applications & Use Cases
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 13 #tatvicwebinar
Examples
● Example 1: Forecast Product Revenue for an eCommerce Store
● Example 2: Assess the long term value of your Marketing Campaigns
● Example 3: Web Analytics Visualization with ggplot2
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 14 #tatvicwebinar
Example 1: Predict Product Revenue with R
● Get Product Revenue as Time Series (historical data)● Forecast Product Revenue for the next quarter
Check out the blogpost for a complete walkthrough - http://bit.ly/1y3dmtI
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 15 #tatvicwebinar
Example 1: Predict Product Revenue with R
Time Series Components
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 16 #tatvicwebinar
Example 2: Long Term Value of Your Marketing Campaigns
Check out the blogpost for a complete walkthrough - http://bit.ly/1zpjbYA
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 17 #tatvicwebinar
Example 2: Long Term Value of Your Marketing Campaigns
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 18 #tatvicwebinar
Query New Customers Acquired via a Given Campaign
query.list <- Init(start.date = "2014-11-01",
end.date = "2014-12-20",
dimensions = "ga:date",
metrics = "ga:transactions,ga:transactionRevenue",
segment = "users::sequence::
^ga:userType==New Visitor;
dateOfSession<>2014-11-01_2014-11-07;
ga:campaign==Campaign A;
->>perSession::ga:transactions>0",
sort = "ga:date",
table.id = tableId)
Example 2: Long Term Value of Your Marketing Campaigns
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 19 #tatvicwebinar
Example 2: Long Term Value of Your Marketing Campaigns
Segments Explained
• The segment selects users:: in order to include not only the sessions that match the conditions, but all sessions among users who match the conditions.
• The sequence:: prefix selects a set of users that completed a specified set of steps
• Step #1 - Visit from a given campaign in a given set of time
• Step #2 - Make a purchase
• The ^ prefix in front of ga:userType==New Visitor;dateOfSession<>2014-11-01_2014-11-07;ga:campaign==Campaign A ensures that the Date of Session, Campaign, and User Type conditions are true for the first hit of the first session in the given date range.
• ->>perSession::ga:transactions > 0 specifies the second step of making a purchase at some point.
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 20 #tatvicwebinar
Example 2: Long Term Value of Your Marketing Campaigns
• head(campaign_a_df)
• cumulativeTransactions <- cumsum(campaign_a_df$transactions)
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 21 #tatvicwebinar
Example 2: Long Term Value of Your Marketing Campaigns
Use the data to Generate a Cumulative Transactions Plot
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 22 #tatvicwebinar
Example 3: Web Analytics visualization with ggplot2
Background
• gg – Grammar of Graphics (Wilkinson, 2005)• R Implementation by Prof. Hadley Wickham• Sophisticated graphs in a *few lines of R code
* Learning Curve
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 23 #tatvicwebinar
Example 3: Web Analytics visualization with ggplot2
ggplot(data = ga.data) + geom_line(aes(x = date, y = itemRevenue)
Check out the blogpost for a complete walkthrough - http://bit.ly/15Iaaf7
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 24 #tatvicwebinar
Example 3: Web Analytics visualization with ggplot2
Decomposing the syntax
• Create the ggplot object and populate it with data • ggplot(ga.data)
• Add Layers(s) • geom_line(aes(x=date, y=itemRevenue))
• Other geoms – bar, point, line, histogram• Aesthetics describe how variables are mapped to visual
properties of geoms• Additional Plotting Options -> Plot title, Axis Titles, Axis Text
Formatting, Legends
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 25 #tatvicwebinar
Best Practices
• Become familiar with the Google Analytics API Naming Conventions
– Dimension/Metric names are in camelCase
• Know the permissible Dimension Metric Combinations
– https://developers.google.com/analytics/devguides/reporting/core/dimsmets
• Use the Query Feed Explorer to test queries before running them in R
– https://ga-dev-tools.appspot.com/explorer/
• Post issues at https://github.com/Tatvic/RGoogleAnalytics/issues
• Questions at Google Analytics Reporting API Forum
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 26 #tatvicwebinar
Further Resources
• http://bit.ly/r-googleanalytics-resources
• Watch the full R Google Analytics Webinar -http://bit.ly/1KrHXtH
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 27 #tatvicwebinar
Outline of this Webinar
An Introduction to R
Why analyze Google Analytics data with R
Getting started with R & Google Analytics
Questions & Answers
3 Real Life Applications & Use Cases
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 28 #tatvicwebinar
Next Webinar
Webinar: Everything You Need to Know aboutGTM V2
When: Feb 18th 10:00 AM PDT Guest Speaker
Phil Pearce(Web Analyst/ PPC/ SEO Expert)
You will learn:• How to Upgrade to GTM V2• Mistakes to Avoid while Upgrading• A Quick Checklist for Upgrading to GTM V2
And much more…
Register Here - http://bit.ly/gtm-v2-webinar
#tatvicwebinar
A GACP and GTMCP company
1/28/2015 29 #tatvicwebinar
Kushan ShahTwitter: @kushan_s
Thank You!
Andy GranowitzTwitter: @agrano