vrijdag 13 februari 2015

Google Analytics in R



Playing around with R using data van Google Analytics, using the following recipes:

Here are some graphs:

Daily visits for 2014

ggplot(myresults, aes(x=date, y=visits))+ geom_point() +
+    stat_smooth()
 

Here data per month and the statistics.


mydata <- ga$getData(id, start.date="2014-01-01", end.date="2014-12-31",metrics = "ga:visits, ga:pageviews", dimensions = "ga:month")

mydata
   month visits pageviews
1      1      0         0
2      2     35        54
3      3     51        76
4      4     79        95
5      5     83       143
6      6     24        24
7      7     27        33
8      8     55        74
9      9    112       153
10    10    326       417
11    11    888      1201
12    12   1120      1596

summary(mydata)
     month       visits         pageviews      
 1      :1   Min.   :   0.0   Min.   :   0.00  
 2      :1   1st Qu.:  33.0   1st Qu.:  48.75  
 3      :1   Median :  67.0   Median :  85.50  
 4      :1   Mean   : 233.3   Mean   : 322.17  
 5      :1   3rd Qu.: 165.5   3rd Qu.: 219.00  
 6      :1   Max.   :1120.0   Max.   :1596.00  

 
Here is a bar graph for visits per month for 2014
barplot(mydata$visits, main="Visits by month", xlab="Month", names.arg=mydata$month, las=1, col=rainbow(9))













Where are the visitors coming from?
mylocal <- ga$getData
(id, start.date="2014-01-01", 
end.date="2014-12-31", 
metrics = "ga:visits", 
dimensions = "ga:country",
sort = "-ga:visits",start = 1, max = 100)


mylocal
                country visits
1         United States    802
2           Netherlands    320
3        United Kingdom    208
4                Canada    192
5                France    163
6               Germany    117
7             Australia     97
8                 Spain     64
9                 Italy     59
10               Israel     50


mysystem <- ga$getData(id, start.date="2014-01-01", end.date="2014-12-31", 
metrics = "ga:visits", dimensions = "ga:browser",sort = "-ga:visits",start = 1,
 max = 100)
> mysystem
             browser visits
1             Chrome   1612
2            Firefox    517
3    Android Browser    275
4  Internet Explorer    241
5             Safari    105
6              Opera     18
7    Safari (in-app)     13
8         UC Browser      9

mysystem2 <- ga$getData(id, start.date="2014-01-01", end.date="2014-12-31",
 metrics = "ga:visits", dimensions = "ga:operatingSystem",sort = "-ga:visits",
start = 1, max = 100)
> mysystem2
  operatingSystem visits
1         Windows   1555
2         Android    825
3           Linux    183
4       Macintosh    144
5             iOS     79
6   Windows Phone      5
7       (not set)      3
8      BlackBerry      3
9       Chrome OS      3


mysystem3 <- ga$getData(id, start.date="2014-01-01", end.date="2014-12-31", metrics = "ga:visits", dimensions = "ga:mobileDeviceBranding",sort = "-ga:visits",start = 1, max = 100)
> mysystem3
   mobileDeviceBranding visits
1                  Asus    507
2               Samsung    127
3                 Apple     79
4             (not set)     48
5               Mozilla     45
6                Google     37
7             Zenithink     19
8                    LG     18
9                  Sony     12
10                  HTC     11
11             Motorola     11
12                Nokia      5
13         SonyEricsson      5
14           BlackBerry      3
15                 Acer      2
16               Sprint      2
 


Geen opmerkingen:

Een reactie posten

Opmerking: Alleen leden van deze blog kunnen een reactie posten.