Skip to content

@willcritchlow /basic-gdata.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
The most basic Google Analytics access in python
import gdata.analytics.service
from datetime import date, timedelta
from xml.dom.minidom import parseString
def main():
client = gdata.analytics.service.AnalyticsDataService()
client.ClientLogin('<your email here>', '<your password here>')
today = date.today()
q = gdata.analytics.service.DataQuery(
ids='ga:<your GA ID here>',
dimensions='ga:pagePath',
metrics='ga:pageviews',
filters='ga:pagepath=~^/store',
sort='-ga:pageviews',
start_date=today - timedelta(days=7),
end_date=today,
start_index='',
max_results='50')
gadata = client.AnalyticsDataFeed(q.ToUri())
xml = parseString(str(gadata))
for title in xml.getElementsByTagName("ns0:title"):
for child in title.childNodes:
print child.data
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.