Drupal Views now supports queries of Google Analytics report data
Views 3 now supports queries against Google Analytics. I've added this experimental module to the 7.x-3.x development release of Google Analytics Reports.
Most popular Google Analytics queries currently pass:
- Most popular content, sorted by most pageviews
- All traffic by search engine, sorted by pageviews in descending order
- Visits broken down by search engine keywords used, sorted by visits in descending order
- Revenue generated through the site for the given time span, sorted by visits in descending order
- New visits vs. returning visits
- Visits by country, sorted by number of visits
- Visits by the Operating System, web browser, and browser version used
- Traffic source and medium, sorted by visits in descending order
The tests above pass, but the code is rough. I have yet to refactor it, and there is some spaghetti code in there that needs to be gobbled up
New Query Type
When creating a new view, select "Google Analytics" from the wizard drop down.
The default display formats of Grid, HTML list, Jump menu, Table, and Unformatted list tend to work as expected. I wasn't able to get Chart Views working very well, unfortunately. It'll take some work to get charts working correctly.
Fields - For both metrics and dimensions
One metric is always required, but you may have several. Dimensions are optional, and you can have as many as you want. It can be a bit tricky to learn when a metric and a dimension are incompatible, but for most general uses, you should be fine. To understand which metrics and dimensions can be used together, use the checkbox on/off tool offered in the Core Reporting API v3 documentation.
Filters - For both metrics and dimensions
The only required filter is the start/end day of the report. We added a default of 2005 if you don't provide a start date. All other filters work mostly as designed. I added a Profile ID filter as well, so you could change which Google Analytics profile you were looking at for this view.
AND/OR groups should also work, but the Core Reporting API has limits in this area. I need to invest some in making this more usable for admins.
Sort - For both metrics and dimensions
Sort works as expected - ascending and descending. I haven't done too many tests with multiple sorts, but the few multiple sorts I tried seemed to work well.
Contextual Filters - For both metrics and dimensions
Like with filters, arguments works mostly as expected. I also added a Profile ID here, so that you could have different report profiles for different views. I'm excited to implementations where Views, with exposed filters, show admins their Google Analytics data across multiple profiles.
All the default paging options should work: Full, mini, limit to a specific number only, and no paging. Exposed pagers should also work fine.
I haven't added any relationships yet, but I am excited about the possibilities.
Please file a billion bugs in the issue queue. I need lots of eyes to help solidify this module.