Friday, October 01, 2010

Python Library for Google Analytics Management API

It’s been only 7 weeks since we’ve launched the Google Analytics Management API and we’ve heard a lot of great feedback. Thanks!

Since Python is one of our more popular languages, we’ve updated the Google Analytics Python Client Library to access all 5 feeds of the Management API. Now it’s easier than ever to get your configuration data from the API.

To show you how simple it is to use the library, here is an example which returns all the goal names for a profile:
import gdata.analytics.client

APP_NAME = 'goal_names_demo'
my_client = gdata.analytics.client.AnalyticsClient(source=APP_NAME)

# Authorize
my_client.client_login(
INSERT_USER_NAME,
INSERT_PASSWORD,
APP_NAME,
service='analytics')

# Make a query.
query = gdata.analytics.client.GoalQuery(
acct_id='INSERT_ACCOUNT_ID',
web_prop_id='INSERT_WEB_PROP_ID',
profile_id='INSERT_PROFILE_ID')

# Get and print results.
results = my_client.GetManagementFeed(query)
for entry in results.entry:
print 'Goal number = %s' % entry.goal.number
print 'Goal name = %s' % entry.goal.name
print 'Goal value = %s' % entry.goal.value

To get you started, we wrote a reference example which accesses all the important information for each feed. We also added links to the source and PyDoc from the Management API Libraries and Examples page. Have a look and let us know what you think!

3 comments:

  1. Very use full information for developers. i think now(after reading this) they can design custom report by doing this...
    Web Designer

    ReplyDelete
  2. Thanks for writing, I very much liked your newest post. I think you should post more frequently. I've been burned by a few SEO companies in the past so when I need to look for a new one,I'm always a little skeptical about things. I'm not giving up though. I know that I need the best seo company I can get on with to really make my website a big hit. I had a friend of mine reccomend www.bergstrom-seo.com. Have you ever worked with them before? Or looked into them? I'm really interested in what your opinion of their work is. Like I said, I'm not giving up on finding the best seo company for me and my needs. I really just want the opinions of some experts out there and if you have any other suggestions I'd like to hear those as well.

    ReplyDelete