SlideShare a Scribd company logo
1 of 63
Download to read offline
100 150 00:01:20
120 300 00:02:15
●
●
●
●
●
●
require(RGoogleAnalytics)
client.id <- "xxxxxxxxxxxx.apps.googleusercontent.com"
client.secret <- "zzzzzzzzzzzz"
token <- Auth(client.id,client.secret)
# Save the token object for future sessions
save(token,file="./token_file")
# Get the Sessions by Month in 2014
query.list <- Init(start.date = "2014-01-01",
end.date = "2014-01-31",
dimensions = "ga:date",
metrics = "ga:sessions",
table.id = "ga:000000")
# Create the Query Builder object
ga.query <- QueryBuilder(query.list)
# Extract the data and store it in a data-frame
ga.data <- GetReportData(ga.query, token)
> head(ga.data)
date sessions
1 20140101 39
2 20140102 46
3 20140103 47
4 20140104 53
5 20140105 49
6 20140106 15
# Get the Sessions by dayOfWeek in 2013
query.list <- Init(start.date = "2013-01-01",
end.date = "2013-12-31",
dimensions = "ga:dayOfWeek,ga:date",
metrics = "ga:sessions",
table.id = "ga:000000")
# Processing Query to ga.data
...
ggplot(data = ga.data, aes(x = dayOfWeek, y = sessions)) +
geom_boxplot()
# Get the Sessions by date in 2013-2015
query.list <- Init(start.date = "2013-01-01",
end.date = "2015-12-31",
dimensions = "ga:date",
metrics = "ga:sessions",
table.id = "ga:000000")
# Processing Query to ga.data
...
# Plot for calendar
calendar_sessions <- ggplot(data, aes(monthweek, weekdayf,
fill = sessions)) +
geom_tile(colour = "white") +
facet_grid(year~monthf) +
scale_fill_gradient(high="#D61818",low="#B5E384") +
labs(title = "Kalendarz") +
xlab("Tydzien miesiaca") +
ylab("")
# View calendar
calendar_sessions
install.packages("devtools")
devtools::install_github("twitter/AnomalyDetection")
library(AnomalyDetection)
# Processing Query to ga.data
...
# Anomaly detection
res = AnomalyDetectionTs(ga.data, max_anoms=0.02,
direction='both', plot=TRUE)
res$plot
...
library(forecast)
...
forecast <- forecast.HoltWinters(forecastmodel, h=26)
# 26 days in future
...
●
●
●
○
●
○
<script>
dataLayer = [{
'level': 'advanced',
'fingerprint' : '123456'
}];
</script>
https://goo.gl/1X84fY
# Get the Sessions by Month in 2014
query.list <- Init(start.date = "2014-01-01",
end.date = "2014-12-31",
dimensions = "ga:dimension01,
ga:contentGroup01",
metrics = "ga:contentGroupUniqueViews01",
table.id = "ga:000000")
# Create the Query Builder object
ga.query <- QueryBuilder(query.list)
# Extract the data and store it in a data-frame
ga.data <- GetReportData(ga.query, token)
> head(ga.data)
Beginner Intermediate Advanced
191352 0 2 42
990977 0 4 32
770561 0 4 48
898022 0 5 21
277510 0 6 31
644227 0 6 44
# K-Means Cluster Analysis
fit <- kmeans(ga.data, 3) # 3 clusters
...
# Append cluster assignment
data.fit <- data.frame(ga.data, fit$cluster)
head(data.fit)
> data.fit
Beginner Intermediate Advanced fit.cluster
266876 9 45 4 1
965265 9 51 7 1
...
981924 19 10 8 2
732529 19 16 1 2
...
377795 2 7 38 3
918083 2 8 28 3
> fit$centers
Beginner Intermediate Advanced
1 7.011765 38.42353 5.023529 # level: intermediate
2 25.530435 10.06087 4.713043 # level: beginner
3 3.628571 5.90000 32.657143 # level: advanced
# 3d chart
install.packages("plotly")
library(plotly)
result <- data.frame(df, fit$cluster)
plot_ly(result, x = result$level1, y = result$level2, z =
result$level3, type = "scatter3d", mode = "markers",
color=factor(result$fit.cluster))
Google Analytics + R. Praktyczne przykłady.
Google Analytics + R. Praktyczne przykłady.
Google Analytics + R. Praktyczne przykłady.
Google Analytics + R. Praktyczne przykłady.

More Related Content

Similar to Google Analytics + R. Praktyczne przykłady.

Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)Dan Robinson
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Johann de Boer
 
Seeking the truth from mobile analytics
Seeking the truth from mobile analyticsSeeking the truth from mobile analytics
Seeking the truth from mobile analyticsMouhcine El Amine
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsLudmila Nesvitiy
 
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...Altinity Ltd
 
Google Analytics for Developers
Google Analytics for DevelopersGoogle Analytics for Developers
Google Analytics for DevelopersRubén Martínez
 
D3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand wordsD3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand wordsApptension
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Miguel González-Fierro
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attributeRichard Martens
 
MCC Scripts update
MCC Scripts updateMCC Scripts update
MCC Scripts updatesupergigas
 
Google Analytics for Developers
Google Analytics for DevelopersGoogle Analytics for Developers
Google Analytics for DevelopersParadigma Digital
 
AdWords Scripts and MCC Scripting
AdWords Scripts and MCC ScriptingAdWords Scripts and MCC Scripting
AdWords Scripts and MCC Scriptingmarcwan
 
Javascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and SinonJavascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and SinonLars Thorup
 
SQL PASS 2017 - Building one million predictions per second using SQL Server ...
SQL PASS 2017 - Building one million predictions per second using SQL Server ...SQL PASS 2017 - Building one million predictions per second using SQL Server ...
SQL PASS 2017 - Building one million predictions per second using SQL Server ...Amit Banerjee
 
Simplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseSimplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseFeatureByte
 
Google
GoogleGoogle
Googlesoon
 
Connecting Your Customers – Building Successful Mobile Games through the Powe...
Connecting Your Customers – Building Successful Mobile Games through the Powe...Connecting Your Customers – Building Successful Mobile Games through the Powe...
Connecting Your Customers – Building Successful Mobile Games through the Powe...Amazon Web Services
 

Similar to Google Analytics + R. Praktyczne przykłady. (20)

Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
Powering Heap With PostgreSQL And CitusDB (PGConf Silicon Valley 2015)
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015
 
Seeking the truth from mobile analytics
Seeking the truth from mobile analyticsSeeking the truth from mobile analytics
Seeking the truth from mobile analytics
 
Protractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applicationsProtractor framework – how to make stable e2e tests for Angular applications
Protractor framework – how to make stable e2e tests for Angular applications
 
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
OSA Con 2022 - Building Event Collection SDKs and Data Models - Paul Boocock ...
 
Cómo usar google analytics
Cómo usar google analyticsCómo usar google analytics
Cómo usar google analytics
 
Google Analytics for Developers
Google Analytics for DevelopersGoogle Analytics for Developers
Google Analytics for Developers
 
D3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand wordsD3.js - A picture is worth a thousand words
D3.js - A picture is worth a thousand words
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
 
Utilising the data attribute
Utilising the data attributeUtilising the data attribute
Utilising the data attribute
 
MCC Scripts update
MCC Scripts updateMCC Scripts update
MCC Scripts update
 
Google Analytics for Developers
Google Analytics for DevelopersGoogle Analytics for Developers
Google Analytics for Developers
 
AdWords Scripts and MCC Scripting
AdWords Scripts and MCC ScriptingAdWords Scripts and MCC Scripting
AdWords Scripts and MCC Scripting
 
Javascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and SinonJavascript unit testing with QUnit and Sinon
Javascript unit testing with QUnit and Sinon
 
SQL PASS 2017 - Building one million predictions per second using SQL Server ...
SQL PASS 2017 - Building one million predictions per second using SQL Server ...SQL PASS 2017 - Building one million predictions per second using SQL Server ...
SQL PASS 2017 - Building one million predictions per second using SQL Server ...
 
2019 WIA - Data-Driven Product Improvements
2019 WIA - Data-Driven Product Improvements2019 WIA - Data-Driven Product Improvements
2019 WIA - Data-Driven Product Improvements
 
Simplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data WarehouseSimplify Feature Engineering in Your Data Warehouse
Simplify Feature Engineering in Your Data Warehouse
 
Metrics stack 2.0
Metrics stack 2.0Metrics stack 2.0
Metrics stack 2.0
 
Google
GoogleGoogle
Google
 
Connecting Your Customers – Building Successful Mobile Games through the Powe...
Connecting Your Customers – Building Successful Mobile Games through the Powe...Connecting Your Customers – Building Successful Mobile Games through the Powe...
Connecting Your Customers – Building Successful Mobile Games through the Powe...
 

More from Michal Brys

Find signal in noise.
Find signal in noise.Find signal in noise.
Find signal in noise.Michal Brys
 
Poznaj lepiej użytkowników Twojego serwisu z Google Analytics
Poznaj lepiej użytkowników Twojego serwisu z Google AnalyticsPoznaj lepiej użytkowników Twojego serwisu z Google Analytics
Poznaj lepiej użytkowników Twojego serwisu z Google AnalyticsMichal Brys
 
Google Tag Manager - first steps
Google Tag Manager - first stepsGoogle Tag Manager - first steps
Google Tag Manager - first stepsMichal Brys
 
Online dashboard using Google Analytics API Measure Camp
Online dashboard using Google Analytics API Measure CampOnline dashboard using Google Analytics API Measure Camp
Online dashboard using Google Analytics API Measure CampMichal Brys
 
A/B testing. Content experiments in Google Analytics
A/B testing. Content experiments in Google AnalyticsA/B testing. Content experiments in Google Analytics
A/B testing. Content experiments in Google AnalyticsMichal Brys
 
Google tools for data analyst
Google tools for data analystGoogle tools for data analyst
Google tools for data analystMichal Brys
 
Google Analytics: dowiedz się więcej o użytkownikach swojego serwisu www
Google Analytics: dowiedz się więcej o użytkownikach swojego serwisu wwwGoogle Analytics: dowiedz się więcej o użytkownikach swojego serwisu www
Google Analytics: dowiedz się więcej o użytkownikach swojego serwisu wwwMichal Brys
 
Odkrywanie wzorców zachowań użytkowników Internetu.
Odkrywanie wzorców zachowań użytkowników Internetu.Odkrywanie wzorców zachowań użytkowników Internetu.
Odkrywanie wzorców zachowań użytkowników Internetu.Michal Brys
 

More from Michal Brys (8)

Find signal in noise.
Find signal in noise.Find signal in noise.
Find signal in noise.
 
Poznaj lepiej użytkowników Twojego serwisu z Google Analytics
Poznaj lepiej użytkowników Twojego serwisu z Google AnalyticsPoznaj lepiej użytkowników Twojego serwisu z Google Analytics
Poznaj lepiej użytkowników Twojego serwisu z Google Analytics
 
Google Tag Manager - first steps
Google Tag Manager - first stepsGoogle Tag Manager - first steps
Google Tag Manager - first steps
 
Online dashboard using Google Analytics API Measure Camp
Online dashboard using Google Analytics API Measure CampOnline dashboard using Google Analytics API Measure Camp
Online dashboard using Google Analytics API Measure Camp
 
A/B testing. Content experiments in Google Analytics
A/B testing. Content experiments in Google AnalyticsA/B testing. Content experiments in Google Analytics
A/B testing. Content experiments in Google Analytics
 
Google tools for data analyst
Google tools for data analystGoogle tools for data analyst
Google tools for data analyst
 
Google Analytics: dowiedz się więcej o użytkownikach swojego serwisu www
Google Analytics: dowiedz się więcej o użytkownikach swojego serwisu wwwGoogle Analytics: dowiedz się więcej o użytkownikach swojego serwisu www
Google Analytics: dowiedz się więcej o użytkownikach swojego serwisu www
 
Odkrywanie wzorców zachowań użytkowników Internetu.
Odkrywanie wzorców zachowań użytkowników Internetu.Odkrywanie wzorców zachowań użytkowników Internetu.
Odkrywanie wzorców zachowań użytkowników Internetu.
 

Recently uploaded

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 

Recently uploaded (20)

Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 

Google Analytics + R. Praktyczne przykłady.

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19. 100 150 00:01:20 120 300 00:02:15
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 27.
  • 28.
  • 29.
  • 30. require(RGoogleAnalytics) client.id <- "xxxxxxxxxxxx.apps.googleusercontent.com" client.secret <- "zzzzzzzzzzzz" token <- Auth(client.id,client.secret) # Save the token object for future sessions save(token,file="./token_file")
  • 31.
  • 32. # Get the Sessions by Month in 2014 query.list <- Init(start.date = "2014-01-01", end.date = "2014-01-31", dimensions = "ga:date", metrics = "ga:sessions", table.id = "ga:000000") # Create the Query Builder object ga.query <- QueryBuilder(query.list) # Extract the data and store it in a data-frame ga.data <- GetReportData(ga.query, token)
  • 33. > head(ga.data) date sessions 1 20140101 39 2 20140102 46 3 20140103 47 4 20140104 53 5 20140105 49 6 20140106 15
  • 34.
  • 35. # Get the Sessions by dayOfWeek in 2013 query.list <- Init(start.date = "2013-01-01", end.date = "2013-12-31", dimensions = "ga:dayOfWeek,ga:date", metrics = "ga:sessions", table.id = "ga:000000") # Processing Query to ga.data ... ggplot(data = ga.data, aes(x = dayOfWeek, y = sessions)) + geom_boxplot()
  • 36.
  • 37. # Get the Sessions by date in 2013-2015 query.list <- Init(start.date = "2013-01-01", end.date = "2015-12-31", dimensions = "ga:date", metrics = "ga:sessions", table.id = "ga:000000") # Processing Query to ga.data ...
  • 38. # Plot for calendar calendar_sessions <- ggplot(data, aes(monthweek, weekdayf, fill = sessions)) + geom_tile(colour = "white") + facet_grid(year~monthf) + scale_fill_gradient(high="#D61818",low="#B5E384") + labs(title = "Kalendarz") + xlab("Tydzien miesiaca") + ylab("") # View calendar calendar_sessions
  • 39.
  • 40. install.packages("devtools") devtools::install_github("twitter/AnomalyDetection") library(AnomalyDetection) # Processing Query to ga.data ... # Anomaly detection res = AnomalyDetectionTs(ga.data, max_anoms=0.02, direction='both', plot=TRUE) res$plot
  • 41.
  • 43.
  • 44.
  • 45.
  • 47.
  • 48.
  • 49.
  • 51. <script> dataLayer = [{ 'level': 'advanced', 'fingerprint' : '123456' }]; </script> https://goo.gl/1X84fY
  • 52.
  • 53.
  • 54. # Get the Sessions by Month in 2014 query.list <- Init(start.date = "2014-01-01", end.date = "2014-12-31", dimensions = "ga:dimension01, ga:contentGroup01", metrics = "ga:contentGroupUniqueViews01", table.id = "ga:000000") # Create the Query Builder object ga.query <- QueryBuilder(query.list) # Extract the data and store it in a data-frame ga.data <- GetReportData(ga.query, token)
  • 55. > head(ga.data) Beginner Intermediate Advanced 191352 0 2 42 990977 0 4 32 770561 0 4 48 898022 0 5 21 277510 0 6 31 644227 0 6 44
  • 56. # K-Means Cluster Analysis fit <- kmeans(ga.data, 3) # 3 clusters ... # Append cluster assignment data.fit <- data.frame(ga.data, fit$cluster) head(data.fit)
  • 57. > data.fit Beginner Intermediate Advanced fit.cluster 266876 9 45 4 1 965265 9 51 7 1 ... 981924 19 10 8 2 732529 19 16 1 2 ... 377795 2 7 38 3 918083 2 8 28 3
  • 58. > fit$centers Beginner Intermediate Advanced 1 7.011765 38.42353 5.023529 # level: intermediate 2 25.530435 10.06087 4.713043 # level: beginner 3 3.628571 5.90000 32.657143 # level: advanced
  • 59. # 3d chart install.packages("plotly") library(plotly) result <- data.frame(df, fit$cluster) plot_ly(result, x = result$level1, y = result$level2, z = result$level3, type = "scatter3d", mode = "markers", color=factor(result$fit.cluster))