Valid combinations of Dimensions and Metrics

3,446 views
Skip to first unread message

Beniamin Ayrapetyan

unread,
Jun 17, 2012, 5:40:36 AM6/17/12
to google-analytics...@googlegroups.com
Hello,

I am using Core Reporting API v3. And have a problem with getting valid combinations of Dimensions and Metrics.
Is there any way I can get it via query, or from documentation? May be some algorithm which may help to determine invalid combinations?

This link: https://developers.google.com/analytics/devguides/reporting/core/dimsmets
did not help me a lot (unfortunately I have no chance to click all combinations, and cannot understand any logic)

ps: sorry for my English :(

Thanks a lot!
Beniamin Ayrapetyan

Jon of All Trades

unread,
Jun 18, 2012, 8:51:17 AM6/18/12
to google-analytics...@googlegroups.com
When I was your age, we didn't have any slick AJAX-driven list where dimensions and metrics were disabled when they became unavailable!  No sir, we just had a list and some vague rules about what did and didn't work.  We had to try it and see!  Kids these days...

Perhaps you'll find this more intuitive:


This Query Explorer tool lets you quickly select some dimensions and metrics and just see if it works.

Beniamin Ayrapetyan

unread,
Jun 19, 2012, 1:25:28 AM6/19/12
to google-analytics...@googlegroups.com
Hello Jon,

I have to create a tool which can be used for create customizable reports based on Google Analytics data. This tool will be used by customer. And my point is to create user friendly UI which do not allow user to select invalid combination of dimensions and metric.

Why I can not use http://ga-dev-tools.appspot.com/explorer/ or https://developers.google.com/analytics/devguides/reporting/core/dimsmets ?
The answer is simple. For example you have two dimensions ga:adSlotPosition and ga:adDistributionNetwork (both dimensions belongs to the same group), and you have metric ga:adCost (same group).
Following combinations are valid:
    1) Dimensions: ga:adSlotPosition
        Metrics: ga:adCost
    2) Dimensions: ga:adDistributionNetwork
        Metrics: ga:adCost
But this one is not:
    3) Dimensions: ga:adSlotPosition;ga:adDistributionNetwork
        Metrics: ga:adCost

May be I am just to young, but for me it means that there is no simple set of rules which I can get using these tools. And I should try all available combinations, but there are 85 dimensions and 92 metrics. It just a lot of combinations.

I know I can make smart tool that will do it for me (and do not check all combinations), but I am just curious is there any documented set of rules which may help me to make more elegant solution?

Luis Pereira

unread,
Jun 19, 2012, 4:56:52 AM6/19/12
to google-analytics...@googlegroups.com
The quickest and easiest way to validate is issueing the query. If the combination is not valid you will get an ILEGAL_QUERY error.

2012/6/19 Beniamin Ayrapetyan <beniamin....@gmail.com>

--
You received this message because you are subscribed to the Google Groups "GA Data Export API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-analytics-data-export-api/-/S8w7hz4e9xkJ.
To post to this group, send email to google-analytics...@googlegroups.com.
To unsubscribe from this group, send email to google-analytics-data-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-analytics-data-export-api?hl=en.

Nick

unread,
Jun 19, 2012, 7:41:02 PM6/19/12
to google-analytics...@googlegroups.com
Yes, the validation rules are quote complex.

Currently, your best bet is to issue the query and see if it works.

-Nick
2012/6/19 Beniamin Ayrapetyan <beniamin....@gmail.com>
To post to this group, send email to google-analytics-data-export-a...@googlegroups.com.
To unsubscribe from this group, send email to google-analytics-data-export-api+unsubscribe@googlegroups.com.

ChiatDev1

unread,
Jun 28, 2012, 8:48:56 PM6/28/12
to google-analytics...@googlegroups.com

Garrett Tichy

unread,
Aug 15, 2012, 3:58:50 PM8/15/12
to google-analytics...@googlegroups.com
Hi Beniamin,

I am not sure you will even receive this response but I can hope.. I am working with the Core Reporting API and am having trouble with specific queries.  It sounds like you are doing something similar but have exceeded where I have made it so far.  If you have a minute and would not mind hearing me out and possibly helping please let me know.  I have posted a topic in the forum as well under PHP Query ..

Thanks in advance,
Garrett Tichy

Jeff Smith

unread,
Nov 6, 2012, 8:39:33 PM11/6/12
to google-analytics...@googlegroups.com
Me, three.  I'm no stranger to hound dogging the documentation, but I'm also under a deadline. Call me Grateful if anyone out there has answers they're willing to share. My context is I'm building a php-mysql-javascript enhancement to a client's site that will show a GA dashboard for various other customer sites.  I've got a basic dashboard up (using the GA EZ Dashboard library), but have identified very few pairs of dimensions and metrics that I'm able to get to work. 

The Core Reporting API documentation states "You can not send a query composed only of dimensions: you must combine any requested dimensions with at least one metric."  As I look through the listed available dimensions, many of them have "none" listed in the Metrics column.  Does this mean they are unavailable for use at this time?  I tried sending a query with just multiple dimensions but so far, no success.  An example would be a pie chart of a region broken down by city.  Perhaps I've missed something obvious in the documentation?

An excerpt from the EZ Dashboard JavaScript lib that I'm trying to use, and how I've loaded it, is below:

<div id='chart-7'>
   <script>
      var chart7 = new gadash.Chart({
      'type': 'PieChart',
      'divContainer': 'chart-7',
      'last-n-days':14,
      'query': {
        'ids': TABLE_ID,
        'dimensions': 'ga:region', 'ga:city'
      },
      'chartOptions': {
        height:200,
        width: 200,
        title: 'Cities'
      }
      }).render();
    </script>   
</div>

When I run this, the div area just shows up empty.  Any insights appreciated.

-Jeff

Nick

unread,
Nov 6, 2012, 8:49:53 PM11/6/12
to google-analytics...@googlegroups.com
So metrics are required and dimensions are optional.

This of it this way.

GA provides totals (metrics). Then you can break down that total by various dimensions.

So for your pie chart, say you want to plot cites. You'll need a metric like visits to define what percentage each slice should be.

In your query object add:

 'metrics': 'ga:visits',
 'sort': '-ga:visits',
 'max-results': 10


Also this tool is nice to test your queries: http://ga-dev-tools.appspot.com/explorer/

-Nick

Jeff Smith

unread,
Nov 7, 2012, 12:42:52 AM11/7/12
to google-analytics...@googlegroups.com
Nick, success! 
  •  Thanks for the recommended modifications to my parms.
  •  Thanks for setting me straight on the what-now-seems-obvious relationship between dimensions and metrics
  •  Thanks for the tool you recommended, which is fantastic, not only as a tester, but as a reference as well.
For other newbies out there using the EZ library, remember (I didn't) that the parameters are case sensitive.  In at least one case I was getting an empty result because I specified 'piechart' instead of 'PieChart'.

I've got a couple of other questions regarding Google Analytics account set-up with regards to my app, are they appropriate for this forum or do they belong somewhere else?

--
 
 

Reply all
Reply to author
Forward
0 new messages