Skip to content


Google Analytics does not do the right thing for segments #2713

changhiskhan opened this Issue · 1 comment

1 participant

Python for Data member

I'm getting an error with the segment option now. When I go to the query explorer, my segments look like this: "gaid::707967480"

So the error I'm getting is related to that string construction - is this a bug, or is this somehow my segment ids?
ValueError Traceback (most recent call last)
in ()
----> 1 df = ga.read_ga(['pagePath', 'date'], dimensions=['avgTimeonPage'], start_date='2012-09-01', segment=['742193199'], secrets='./client_secrets.json')
2 df

C:\Python27\lib\site-packages\pandas-0.10.0-py2.7-win32.egg\pandas\io\ga.pyc in read_ga(metrics, dimensions, start_date, kwargs)
94 reader = GAnalytics(
95 return reader.get_data(metrics=metrics, start_date=start_date,
---> 96 dimensions=dimensions, **kwargs)
98 class OAuthDataReader(object):

C:\Python27\lib\site-packages\pandas-0.10.0-py2.7-win32.egg\pandas\io\ga.pyc in get_data(self, metrics, start_date, end_date, dimensions, segment, filters, start_index, max_results, index_col, parse_dates, keep_date_col, date_parser, na_values, converters, sort, dayfirst, account_name, account_id, property_name, property_id, profile_name, profile_id, chunksize)
284 if chunksize is None:
--> 285 return _read(start_index, max_results)
287 def iterator():

C:\Python27\lib\site-packages\pandas-0.10.0-py2.7-win32.egg\pandas\io\ga.pyc in _read(start, result_size)
279 except HttpError, inst:
280 raise ValueError('Google API error %s: %s' % (inst.resp.status,
--> 281 inst._get_reason()))

ValueError: Google API error 400: Invalid value 'ga:742193199' for segment.

@changhiskhan changhiskhan was assigned
Python for Data member

fixed. also able to handle dynamic segment: segment='source=~twitter'

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.