Guide to set-up credentials in RGoogleAnalytics API

[This article was first published on R – JC Chouinard, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This is a walkthrough for creating the project and generating the client id and client secret that you will need to set-up SEO split testing.

This implementation Guide will help you using Google Analytics with R so you can extract your Data in RStudio

Create your first Google API project (Step-By-Step)

It is your first time using a Google API, or even using an API? Don’t worry, this step-by-step guide will walk you through the way to create your RGoogleAnalytics project.

Step 1: Create your Own Project in Google API Console

Go to Google’s developers console, and go through the sign-in process if it is your first time using it.

In Google Cloud’s console, we will set-up our credentials as you can see in the video. Here, I will add credentials called r-seo-split-test.

Click Select a project > New Project


set up credentials

Step 2: Activate the Google Analytics Reporting API

  1. Go to Dashboard
  2. Click Enable APIs and Services
  3. Search for “analytics”
  4. Select Google Analytics Reporting API
  5. Enable

enable apiIf you are a beginner with R and you want to import your Google Analytics Data with RGoogleAnalytics package, you will need to set up your project in Google Analytics API.

Step 3: Create your credentials

Now that you activated the reporting API, you get a message from Google telling you that you need credentials

To use this API, you may need credentials. Click ‘Create credentials’ to get started.

Indeed, you will need to store your and your client.secret which you now need to generate.

At this point, I find it easier to go in the credential tab on the left instead of only clicking “create credentials”.

1. Create credentials

create your credentials

2. Select OAuth client ID

auth client id

3. Set product name on consent screen

At this step, click on Configure consent screen and give your product a name.

configure consent screen

Here, I will call my product name “r-studio-credentials” and leave the rest of it blank since it is all optional. Click Save.

create google analytics api a name

4. Choose Application Type

For the application type, select other and name it. I will call it rstudio-client.

 creat oauth client ID 

Step 3: Save your and client.secret

You now have generated your and your client.secret, congratulations. Store it somewhere safe, you will need it to make your API call from RStudio and import Google Analytics Data.

copy client id and client secret

This is the end of the tutorial to help you create your project in Google Analytics API. Next. I will show you how to make your first API call from RStudio using RGoogleAnalytics Package.

Other APIs You Might Be Interested In

Looking for the next steps to improve your skills using APIs?

jean-christophe chouinard seo expert in quebec city

Sr SEO Specialist at Seek (Melbourne, Australia). Specialized in technical SEO. In a quest to programmatic SEO for large organizations through the use of Python, R and machine learning.

L’article Guide to set-up credentials in RGoogleAnalytics API est apparu en premier sur JC Chouinard.

To leave a comment for the author, please follow the link and comment on their blog: R – JC Chouinard. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)