Archive for category Google API

Using the Google Analytics API - getting total number of page views

At long last, Google released the Google Analytics API.  The timing couldn’t be better, since I was just trying to get to some information through screen scraping… which is never fun.

The API is pretty easy to use, and other than a typo which slowed me down way too much, it didn’t take long to write a simple PHP script to get the total number of page views across all my Analytics profiles.  This is a quick tutorial for using the API for this simple purpose.  Also check out the official API documentation.

The basic steps involved are:

1. Authenticate the user and get a one-time token from Google
2. Exchange the one-time token for a session token, which does not expire
3. Retrieve and parse a list of the user’s Google Analytics accounts and profiles
4. Retrieve and parse the page view count for each profile
5. Done!

Read the rest of this entry »

49 Comments