0
votes

I can easily set custom dimensions in Google Analytics as

ga('set', 'dimension2', '100');

The data can be seen in Analytics also. But I cannot use filter by the custom dimension while querying via Google Analytics API like

'filters'=>'ga:dimension2==100'

The error says :

"message":"Unknown dimension(s): ga:dimension2\nFor details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets."}],"code":400,"message":"Unknown dimension(s): ga:dimension2\nFor details see https://developers.google.com/analytics/devguides/reporting/core/dimsmets."}}

Please help me to query analytics with filter by custom dimension.

1
Are you sure you're querying the right property using the GA API? And are you sure you're using the right index (2)?faridghar

1 Answers

1
votes

Custom Dimensions are defined at the web property level, is it possible you are querying that filter on a view that does not belong under the web property you defined the dimension under?

You can also double check that you are using the correct dimension id with the Management API.

https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtReference/management/customDimensions/list