Search code examples
pythongoogle-analyticsgdatagoogle-analytics-api

How to get details of GA by python


I need to get the data from Google analytics API to python code.I'm using gdata python module for this. But from that we only can get limited details like visits , visitors , page views. The code snippet is following:

    data_query = gdata.analytics.client.DataFeedQuery({
  'ids': table_id,
  'start-date': today.isoformat(),
  'end-date': today.isoformat(),
  'dimensions': 'ga:date,ga:source',
  'metrics': 'ga:visits,ga:pageviews',
    })            

feed = client.GetDataFeed(data_query)

Is there a way to get the details of a particular hit in the list. Please see the image and I need to get each details (the string appear in the hit) on each line in the hits list. Is there any other python library to do this ?

List of hits to GA

Thanks.


Solution

  • What you want to use is dimension ga:pagePath and metrics ga:visits and you should have a report similar to the one in the screenshot.

    You can find the full list of metrics/dimensions here.

    https://developers.google.com/analytics/devguides/reporting/core/dimsmets/pagetracking