How to Set Up Google Analytics API: Step by Step Guide

InsightWhale
5 min readOct 15, 2020

Let’s be honest. We all know setting up Google Analytics API as opposed to using the regular Google Analytics user interface opens much broader horizons for things like hierarchical traffic and time-sensitive attribution analysis.

Learning how to set up Google Analytics API presents great advantages to those who want to get the best out of their data and are not afraid to work for it. Ready to satisfy your advanced analytical needs?

Let’s do it!

Source

Step 1: Create a new project

The first step on your way of setting up your Google Analytics API is to create a new project. To begin, press the link right here — https://console.developers.google.com/projectcreate.

Here you’ll see a window which will prompt you to pick a new project name, confirm your company and location, and once you’re done with that press Create.

Step 2: Enable Google Analytics API

Now that we have a new Google Analytics reporting project to work on, you’ll see a new dashboard open up to you which will look something like the image below:

Exciting, right? Now scroll down and look on your left. You’ll see a block called Getting Started and right below it a title called Explore and enable APIs. Click on it.

Here you’ll be redirected to a new page to be reminded that you don’t have any APIs available to use (yet). To enable Google Analytics API, go to the top of your page to the Search for APIs and Services search bar > type Google Analytics Reporting API > choose the first item.

You’ll see a new window which tells you about the perks and advantages of reporting with Googe Analytics Reporting API, and now all you have to do is press the blue square called Enable.

There is a whole Google API library you can review to enrich your reports or just to know what’s out there, so make sure you don’t mistakably choose Google Analytics API or Google Analytics Data API instead of the right one.

Step 3: Create Google Analytics API credentials

Yay! We’ve just learned how to enable Google Analytics Reporting API and now all that’s left to do before you start using it is to get your Google Analytics API key. What’s this magical key and how do I get it, you’d ask?

It’s all quite simple, our dear friend, as a Google Analytics API key simply serves as a password that authorizes your access to the data you’ve asked for. At the time of the key transfer, the Google Analytics server reviews the access rights of this key and determines whether it is permissible to send data via API or not.

To get Google Analytics API key you’ll need to take a couple of final steps. After you’ve clicked Enabled in the second step of this tutorial, your page was automatically redirected to a report data overview, which looks something like this:

Now look at the top of the page and right under the word Overview you’ll see a grey bar with a big CREATE CREDENTIALS button right next to it, click on it. Now all you have to do is indicate the API you’re using, where you’ll be calling it from and the type of data and click What credentials do I need?

Now be careful here. You’ll have an additional step open in a new window which we’ll review in a second, but just remember to keep the current window open as well. Okay, let’s continue.

Step 4: Fill out OAuth consent screen

Once you press the blue What credentials do I need? button you’ll be shown a small pop-up window where you choose Set up consent screen > pick internal or external user type > leave blank or fill out the OAuth consent screen > Save.

This is the final OAuth consent window you’ll get which you can now safely close and get back to the previous screen we’ve asked you to keep open called Credentials.

Step 5: Get Google Analytics API keys

Now that we’ve come back to our original Credentials window you can give a name to your OAuth Client ID, add restrictions if you wish to and press Create OAuth Client ID > Download > Done.

Voilà! You now have a downloaded file with your Client ID and Client secret which serve as the required API keys we’ve been needing all alone 🙂

Conclusion

Hurray! You did it! You’ve successfully set up Google Analytics API and got the API keys that will now let you use your data in ways that before were not even possible! 🙂

To broaden your toolbox, take a look at our other hands-on Google Analytics articles:

Originally published at https://insightwhale.com on October 15, 2020.

--

--

InsightWhale

Fully remote team of professionals providing Digital Analytics, Conversion Rate Optimization and Business Intelligence services for clients around the world.