Search code examples
google-analyticsgoogle-analytics-api

Google Analytics API errors on custom dimension


Does google support selecting and filtering of custom dimensions in its API? It errors out every time I try to make a query with ga:dimension1

Client code:

    //analytics.js include on the previous line        
    ga('create', 'UA-50XXXXXX-1', 'domain.com');
    ga('set', 'dimension1', 'var1' );
    ga('set', 'dimension2', 'var2' );
    ga('set', 'dimension3', 'var3' );
    ga('require', 'displayfeatures');
    ga('send', 'pageview');

I go to https://ga-dev-tools.appspot.com/explorer/ and put in my account info, ga:pageviews as the metrics and ga:dimension1 as the dimensions and it gives me this as a Query URI:

    https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3AXXXXXXXX&dimensions=ga%3Adimension1&metrics=ga%3Apageviews&start-date=2015-02-20&end-date=2015-02-26&max-results=50

When I run the Query URI it returns:

    Ack! There was an error!
    400 : Unknown dimension(s): ga:dimension1

Do I need to enable something on my account? Do I need to go back to ga.js and custom vars


Solution

  • The most likely explanation is that you haven't enabled custom dimensions on your property in Google Analytics.

    This article should explain how if you're unsure:
    https://support.google.com/analytics/answer/2709829