Content Drilldown with the Google Analytics Core Reporting API

Wednesday, 17 December 2014

⚠️ This is an old post

It's possibly been exported and imported from at least three different blogging platforms over the years. That probably means, at best, there are broken images and links. If the post is technical in nature, any advice is probably out of date and irrelevant. Or it is really old, it was the wafflings of a teenager with too much time on his hands working out what blogging is… If it is the latter I would probably cringe if I re-read it. But it's here because it's part of my past, not my present.

You've been warned! Onwards…

Today I’ve been trying to replicate the content drilldown function from Google Analytics through their Core Reporting API. The solution I came to requests pagePathLevel# in the dimension, and then filters on various pagePathLevel#:

For example if you wanted to the page views for the content drilldown at /level1/level2/level3 you could run this:

id=ga:#######
metrics=PageView, Sessions, etc
sort=-ga:page views
start-date=2014–11–16
end-date=2014–12–16
filters=ga:pagePathLevel1==/level1/;ga:pagePathLevel2==/level2/
dimensions=ga:pagePathLevel3

A handy tool to test these queries is the Google Analytics Query Explorer.

In my case I wanted to get a list of the most popular exhibitions at the V&A. The URL structure is: content/exhibitions/[expo-slug], so the query I am running is:

id=ga:#######
dimensions=ga:pagePathLevel3
metrics=ga:pageviews
filters=ga:pagePathLevel1==/content/;ga:pagePathLevel2==/exhibitions/
sort=-ga:pageviews
start-date=2014–11–16
end-date=2014–12–16
max-results=50

Right now, Constable and Horst are top of the list!

Hopefully this will help someone else.

Back to all posts