GAR-package: Authorize and Request Google Analytics data.

Description Details Author(s) References See Also Examples

Description

This package is designed to aid in obtaining initial authentication with Google Analytics using the getCode() and getRefresh() functions.

Once authenticated you will have an refresh token which can be repeated traded for an access token via the tokenRefresh() function. Once traded for an access token, data can be retreived used the gaRequest() function.

It is recommended to store the client id and client secret in the following system variables: GAR_CLIENT_ID, GAR_CLIENT_SECRET. The getCode(), getRefresh() and tokenRefresh() functions will reference these variables by default. It is also recommended to store the refresh token retreived by getRefresh() in a GA_REFRESH_TOKEN system variable. The tokenRefresh() function will refer to GA_REFRESH_TOKEN by default.

Additionally, a package environment (envGAR) is created on load and will store the access token produced by tokenRefresh() for use within the session.

Details

Package: GAR
Type: Package
Version: 1.2
Date: 2015-03-10
License: R Version 3.1
Depends: httr, jsonlite

Package includes four main functions: getCode(), getRefresh(), gaRequest(), getMeta() and tokenRefresh().

Author(s)

Andrew Geisler

Maintainer: Andrew Geisler <andrew.geisler@gmail.com>

References

https://developers.google.com/analytics/devguides/reporting/core/v3/ https://developers.google.com/analytics/devguides/reporting/metadata/v3/

See Also

GAR gaRequest getCode getRefresh tokenRefresh getMeta

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
getCode(
        client_id="ABCDEFG"
        )

getRefresh(
            client_id="ABCDEFG",
            client_secret="HIJKLMNOP",
            code="QRSTUVWX"
            )

gaRequest(
        id=c('ga:123456789','ga:987654321'), 
        dimensions='ga:date,ga:month', 
        metrics='ga:sessions,ga:users,ga:pageviews', 
        start='YYYY-MM-DD',
        end='YYYY-MM-DDD',
        sort='-ga:sessions,ga:users',
        max='1000',
        filters='ga:browser==VALUE,ga:city==VALUE',
        segment='abcdef',
        token='abcdef',
        allResults=FALSE
        )

tokenRefresh(
            client_id="ABCDEFG",
            client_secret="HIJKLMNOP",
            token="QRSTUVWX"
            )

getMeta()

)

andrewgeisler/GAR documentation built on May 10, 2019, 10:31 a.m.