Python Library for Google Analytics Management API

OCT 01, 2010
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!

By Nick Mihailovski, Google Analytics API Team