README.md

GAplotR

Overview

GAplotR is a simple tool which generates chart image files from Google Analytics data. Its purpose is:

Key Features

Installation

GAplotR is still under development. You can install this package by using devtools

library(devtools)
install_github('hkjinlee/gaplotr')

GA configuration

You need to start from adding new views of Google Analytics.

Configuration file format: JSON

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"
}

Multiple configuration files

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

Usage

Authentication on the first execution

library(gaplotr)

gaplotr <- gaplotr::gaplotr()

Customization

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')

Execution

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)


hkjinlee/gaplotr documentation built on May 17, 2019, 4:33 p.m.