I'm trying to generate charts in Views using Google Analytics data.

I have the Google Analytics Reports module installed, but this module doesn't allow aggregation of data which make charts very difficult to develop.

Does anybody have a working solution to get charts in Drupal 7 using Google Analytics data?

  • Where is the Google Analytics data now? Commented May 28, 2013 at 15:11
  • On Google's site...accessible by API.
    – Ken J
    Commented May 28, 2013 at 16:27
  • The sketch of how my friend did it: Import data to database table, expose it to views, aggregate and display using views and their plugins. I've only seen it working, so can't give you a real detailed answer.
    – Mołot
    Commented May 29, 2013 at 6:56

3 Answers 3


You could pull in the data to your Drupal DB via the Google Analytics API (https://developers.google.com/analytics/devguides/config/mgmt/v3/mgmtDataImport)

Then create views to display the reports/charts you want. Then install and build data visualizations packages like Views Dataviz with Google Charts API.


Use the 7.x-3.x version of Google Analytics Reports

As of Jul 31, 2015, the Google Analytics Reports module completed the Migrating from the Chart to the Charts module. Refer to my answer to "How to transform data from the Google Analytics Reports module into charts?" for new options (features) that became available as of the 7.x-3.x version of that module, and which may better fit your needs.

Roll your own cookies

If you'd rather want to consider an alternative, you could try to create those charts, by just using the Charts module to achieve your goal. After importing relevant data (as suggested in another answer also), you could use either its Views integration, or its API (in your custom module). The Charts Community documentation may help to do so also.

Specific to your question here, there is an interesting Charts-issue you may want to look at. I.e. Graph node input over time (support date formatting on a continuous axis). In Comment #3 of that issue is stated: 'The trouble here is that neither Views nor Date modules provide aggregation options for date-based fields.'.

Part of the recommended solution there is to (also) use the Views Date Format SQL module. Here are some details (from its project page):

The Views Date Format SQL module allows to format date fields using SQL. This enables group aggregation for date fields using the choosen granularity.

The core functionality is to remove the date formatting from render() and put it in query(). I.e. format date values using SQL's DATE_FORMAT rather than PHP's format_date. This is achieved by assigning a new default handler to node 'created' and 'changed' date fields. This handler extends and overrides views's build in views_handler_field_date.

The UI is completely unobtrusive, only a single checkbox "Use SQL to format dates" is added to the handler configuration popup.

Disclosure: I'm a co-maintainer of the Charts module.


activate the 3 submodules of charts module and the google analytics report module will display charts


Using google analytics report module + charts module with its 2 sub-modules do generate a chart by defaut.

The corresponding view can be modify and implemented with GA variables and chart add-ons.

I have not been trying to customize charts further than exposing some filters so i can't talk of limitations when trying to create specific custom charts with these views

  • Which submodules of charts do you mean? To my knowledge, these only 2 submodules that exist are the ones at cgit.drupalcode.org/charts/tree/modules ... and those submodules only enable the charting rendering engine of your choice ... provided the (main) Charts module passed the appropriate input to either one of them. While the question here, IMO, is rather about how to put the required input together ... starting from Google Analytics data. Commented Mar 24, 2016 at 10:40
  • right i meant charts + the 2 submodules and for the exact problem with agreagation i dont quite get it but the module do display charts and allow extension on the defaut chart with chart add-on
    – Matoeil
    Commented Mar 24, 2016 at 11:33
  • I suggest you enhance your answer to include your prior comment. While you do, please be more specific (which "submodules" you mean). About the "problem with aggregation": know that (a) there is a new version of G.A.R. these days and (b) there is a "week" module dependency to the Charts module in that new release. Refer to the linked answer in my answer below for way more details ... Commented Mar 24, 2016 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.