Steps
1. Go to https://console.developers.google.com
2. Create a new Project
3. Go to API and select Analytics API (used in this e.g.)
4. Go to Consent Screen and fill the appropriate product name and save
5. Go to credentials and creat a new client ID
Make sure u enter the website URL properly
6. Now run the following R script
R Script
require(RGoogleAnalytics)
client.id="xxxxxxxxxxxxxxxxxxx"
client.secret="xxxxxxxxxxxx"
token <- auth="" client.id="" client.secret="" p="">ValidateToken(token)
query.list <- init="" p="" start.date="2014-01-01"> end.date = "2014-02-10",
dimensions="ga:date,ga:pagePath,ga:hour,ga:medium",
metrics = "ga:sessions,ga:pageviews",
max.results=500,
sort="-ga:date",
filters="ga:medium==referral",
table.id ="ga:xxxxx"
)
ga.query <- p="" query.list="" querybuilder="">ga.data <- ga.query="" getreportdata="" p="" token="">
7. Check the output
->->->->
1. Go to https://console.developers.google.com
2. Create a new Project
3. Go to API and select Analytics API (used in this e.g.)
4. Go to Consent Screen and fill the appropriate product name and save
5. Go to credentials and creat a new client ID
Make sure u enter the website URL properly
6. Now run the following R script
R Script
require(RGoogleAnalytics)
client.id="xxxxxxxxxxxxxxxxxxx"
client.secret="xxxxxxxxxxxx"
token <- auth="" client.id="" client.secret="" p="">ValidateToken(token)
query.list <- init="" p="" start.date="2014-01-01"> end.date = "2014-02-10",
dimensions="ga:date,ga:pagePath,ga:hour,ga:medium",
metrics = "ga:sessions,ga:pageviews",
max.results=500,
sort="-ga:date",
filters="ga:medium==referral",
table.id ="ga:xxxxx"
)
ga.query <- p="" query.list="" querybuilder="">ga.data <- ga.query="" getreportdata="" p="" token="">
7. Check the output
->->->->
Comments