Description Usage Arguments Details Value Author(s) References See Also Examples
This function compiles a Google Analytics API request, retrieves the results and outputs a dataframe. Input formats based on documented Google Analytic's Core Reporting API requirements. The function is designed to loop through the same request to multiple GA account ids. The result will still be one data frame. Additionally, the function attemps to output the error message if there is an issue. By default, the function will use the GAR_ACCESS_TOKEN variable set by the tokenRefresh() function. However, a supplied token value will take priority over stored variabled.
1 2 3 4 |
id |
Required. Profile ID including the ga: prefix. Can be a more than one. See example below. |
dimensions |
Not Required. Parameter can be a single dimension or a string of multiple dimensions separated by commas. |
metrics |
Required. Parameter can be a single metric or a string of multiple metrics separated by commas. |
start |
Required. Start date formated as a string (YYYY-MM-DD). |
end |
Required. End date formated as a string (YYYY-MM-DD). |
token |
Required. |
sort |
Not Required. Can be a single parameter or can be a string of multiple parameters separated by commas. |
max |
Not Required. Google Analytics default is 100 and their max is 10,000. |
segment |
Not Required. |
filters |
Not Required. Can be a single parameter or can be a string of multiple parameters separated by commas. |
allResults |
Logical. TRUE will cause the function to paginate through all results. Max also needs to be set to 10000. Warning, pagination could increase run time. |
The function returns a dataframe.
profileId |
Profile/view ID in request. |
accountId |
Account ID. |
webPropertyId |
Property UA number. |
internalWebPropertyId |
Internal web property ID. |
profileName |
Name of profile in the request. |
tableId |
Table ID from Google Analytics. |
start.date |
Start date of the request. |
end.date |
End date of the request. |
dimension(s) |
Each requested dimension will be a separate field in Data Frame. |
metric(s) |
Each requested metric will be a separate field in Data Frame. |
Andrew Geisler
https://developers.google.com/analytics/devguides/reporting/core/v3/
GAR
gaRequest
getCode
getRefresh
tokenRefresh
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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',
allResults=FALSE,
token='abcdef'
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.