Google Analytics API – Lesson 4: Authentication

If you’ve been with us through the entire series, welcome back! This time we’ll get in and get our hands dirty in some code. If you haven’t been with us for the series, start by reading the first part of the series, which discusses some background, and the second part of the series. We also have added the third part of the series which prefaces today’s lesson.

Picking Up Where We Left Off

The next step in the process is to start editing and uploading the files. Before we begin editing files, we must first get the information to place in the files. This part is mainly Google’s authentication.

Well, How Does the Authorization Work?

Google uses Auth 2.0 with a special token to authenticate a user. If you have ever allowed an app to access your Google information, this is the same process. When you use a Google app, which is what we will be developing, it will first request access by you. This will require a Google login from the account you wish to use the app with. Then, it will ask for your permission for the app to access your account. Finally, it will return an authorization token to the application. This token has an expiration. It also may expire early depending on your browser settings.

Where do I go to Authorize?

To get your information for authorization, head over to the Google API Console. When in the console and logged into the appropriate account, click the dropdown in the upper left hand corner to create a new project. Name the project any name you choose.

API Project

Once you have created a project, navigate to the services page. Ensure that you turn on the Analytics API. Once you have completed that, click the ‘API Access’. This will take you to an area where you can generate the keys you will need.

For our purposes, we’re going to be doing a web application. We are still working in PHP for this project. All of the demonstrations will be live and on the web. Input the appropriate information here.
After you have submitted the client ID settings, you’re done! You will be redirected to the API access page, where you can see all of the information.

What if it breaks!?

Luckily, you can’t exactly break this one. However, as we move forward with more coding, you will need to keep an eye on these settings. There are some errors that you may run into that could be caused by the settings you made here.
For the next installment, we will be discussing how to actually implement these items into the previously downloaded code. From there, we will move forward with uploading and testing the application!

Have more questions about starting with the Analytics API? Tell us in the comments, and stay tuned for the next part of the series!

Subscribe to our Blog

Recent Posts

Categories

see all

Archives

see all