Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Drill-Down Custom Dimensions in Analytics API

Not applicable

Our APIs are location-driven and so we are recording a custom dimension of "location."

Using Management UI, a Custom Report can allow us to start with a list of transactions by Developer App, and then drill down from there to see all the locations that a particular Developer App requested.

But I can't figure out how to replicate this same drill down using the Analytics APIs. I want to retrieve the count per location but filter by Developer App. How can I go about this? Thanks!

Solved Solved
0 9 1,583
2 ACCEPTED SOLUTIONS

Not applicable

Hi @Jeof Oyster , Are you saying that you are unable to filter using a custom dimension ?

That is possible . Can you try with 'in' instead of 'IN' ?

example :

/v1/o/org/e/senv/stats/x_forwarded_for_ip?select=sum(message_count)&timeRange=06/01/2015%2000:00~06/03/2015%2000:00&timeUnit=day&filter=%28x_forwarded_for_ip+in+%27120.70.20.228%27%29

View solution in original post

Not applicable

Hello Jeof

What in custom reports is shown as a drill down, is translated into the API call as a filter condition. A filter condition is very similar to a WHERE clause in SQL and if you are familiar with it, you will find the Analytics filter easy to use. Please keep in mind that the syntax is similar, but that it will not support all the flexibility that you have in a real transactional DB dialect.

Filters are sent as a query parameter named “filter”.

Every condition has the following form:

{dimension} {operator} {value or values to compare}

Where operator can be “eq” (=), “ne” (!=), “gt” (>), “lt” (<), “ge” (>=), “le” (<=), “in” and “notin” (not in)

A note here, operators are case sensitive, “IN” will not work, you need to use “in”.

For example, you can say:

…/{org}/environments/prod/stats/{custom dimension}?select=sum(message_count)&timeRange=06/01/2015%2000:00~06/03/2015%2000:00&timeUnit=day&filter=(client_id in 'ABC123')

You can use in a filter any dimension listed in your environment schema, the same thing with the group by dimension (the fragment after ../stats/ ).

To retrieve the schema for your environments, use:

…/{org}/environments/{env}/analytics/admin/schema?type=fact

You can also use several conditions using “and” or “or” operands.

Note. Keep your parenthesis in your filter condition at minimum, handling nested parenthesis is not well supported.

I hope this helps.

View solution in original post

9 REPLIES 9