GAplotR is a simple tool which generates chart image files from Google Analytics data. Its purpose is:
GAplotR is still under development. You can install this package by using devtools
library(devtools)
install_github('hkjinlee/gaplotr')
You need to start from adding new views of Google Analytics.
Create ga
directory under your working directory, and put a per-site configuration file there, which looks like this. Change view_id
to one of your own.
{
"site_name": "some_project"
"view_id": "ga:XXXXXXX"
}
You can add as many views at the same time. Configuration files can have any name you like, once it has '.json' extension.
hkjinlee-mac:ga hkjinlee$ ls
onestore_app.json onestore_web.json
library(gaplotr)
gaplotr <- gaplotr::gaplotr()
You can create your own configuration file for customization. For configuration file format, please refer to default config file. These default values are overridden by custom configuration, if any.
library(gaplotr)
gaplotr <- gaplotr::gaplotr('path/to/configfile.json')
The example below will generate three charts, of which output directory is figure
under cwd
.
library(gaplotr)
gaplotr <- gaplotr::gaplotr()
getChartParams <- function(type) {
list(
type = type,
title = paste(type, '차트'),
filename = paste0(type, 'chart.png')
)
}
ga_params <- list(
site_name = 'onestore_app',
view_id = 'XXXXXXXX'
)
query <- list(
dimensions = "ga:date",
metrics = c("ga:users", "ga:newUsers"),
`start-date` = "7daysAgo",
`end-date` = "today"
)
gaplotr$generateChart(ga_params, getChartParams('line'), query)
gaplotr$generateChart(ga_params, getChartParams('bar'), query)
gaplotr$generateChart(ga_params, getChartParams('table'), query)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.