Google Analytics API More then 7 dimensions


Please Share

DimensionsMetrics

Have you ever wanted to request more than 7 dimensions from the Google Analytics API?   Does this Limitation frustrate you?  Are you looking for a work around to allow you to request more then 7 dimensions from the Google Analytics API.   I have a work around that you might find useful. I came up with this solution while working on a Google Analytics project where I needed to request more data,  I like to call Creative Filtering.

Drawback

The draw back’s to creative filtering is that you will end up sending more query’s to the Google Analytic’s API so you need to take your quota limit into account when doing this.   Remember each user is allowed a maximum of 10,000 query’s a day.   Which is a lot so I haven’t currently run into a problem with this… Yet.    Make sure that you are including quotaUser in all your queries.  If you don’t all your users will be lumped into the same user and then they all in total have the 10,000 query limit per view.

Creative filtering

The idea behind creative filtering is to run the same 7 dimensions with different filter values.

Here is my query.

  1. ga:date
  2. ga:country
  3. ga:city
  4. ga:networkDomain
  5. ga:LandingpagePath
  6. ga:exitPagePath
  7. ga:campaign

As you can see I now have 7 dimensions.   But I want more information.    A good dimension to use with creative filtering is ga:visitorType.     Visitor type only has 2 values that it can be New Visitor, Returning Visitor .

Here comes the magic of creative filtering.    What I want to do is get ga:visitortype as a dimension as well.  So I will need to run my query twice.   Once with the filter of filter=ga:visitorType=New Visitor   and again with a filter of filter=ga:visitorType=Returning Visitor 

Here is what they will look like.

Dimensions=ga:date,ga:country,ga:city,ga:networkDomain, ga:LandingpagePath,ga:exitPagePath,ga:campaign&metrics=ga:visits&filter=ga:visitorType=New Visitor

Dimensions=ga:date,ga:country,ga:city,ga:networkDomain, ga:LandingpagePath,ga:exitPagePath,ga:campaign&metrics=ga:visits&filter=ga:visitorType=Returning Visitor

Creative Filtering dimensions

I know of several dimensions where this works.

  • ga:isMobile   The possible values are Yes or No
  • ga:deviceCategory The type of device: Desktop, Tablet, or Mobile.
  • ga:visitortype Possible values: New Visitor, Returning Visitor.
  • ga:date  Assuming you aren’t querying on to many days you can just filter on the date and loop it that way.

I would not recommend doing it on say ga:LandingpagePath you would have to run one query for each of the potential landing pages on your site.   There would be to many.   The only way to do this efficiently is if the dimension has a limited number of possible values.   You can string more then one creative filter dimension on just separate them with a “;”.

Quota

You need to remember that for every value of the filter you are going to be adding more query’s that you will need to run.   I had one that I managed to get up to 80 requests just to get the data back that I needed.    So always take your Quota into account before you try this.

Conclusion

The fact that the Google Analytics API limits us to only 7 dimensions can be very frustrating when you would like to see more data.   Creative filtering will allow you to get a few more columns, it may not fix the problem entirely but it does help a little.

Please Share


Linda Lawton

About Linda Lawton

My name is Linda Lawton I have more than 20 years experience working as a developer and a database expert. I have been working with several of the Google APIs, since 2012. I helping others in the On-Line community to develop with the Google APIs, by creating my own blog www.daimto.com. This and my presence on a number of On-Line developer forums lead me to be noticed by the Google Analytics API development team. I was nominated for and recently became one of the first Google Developer Experts for Google Analytics.

Leave a comment

Your email address will not be published. Required fields are marked *