Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Update! This documentation has been moved into child pages (see below).
Google Analytics Reports module provides graphical reporting of your site's tracking data. Graphical reports include small path-based report in blocks, and a full path-based report.
For installation and configuration help, plus examples, please visit one of the following child pages:
Comments
The chart example above is no
The chart example above is no longer valid. When attempting to run this I'm getting:
[28-May-2013 23:15:07 UTC] PHP Fatal error: Cannot use object of type stdClass as array in /sites/all/modules/custom/mymodule/includes/ga_examples.inc on line 19
I can dump the contents of the array but it looks like it needs to be called as objects ($feed[0]->visits) rather than as an array.
## Note: The above code is fictitious. Any resemblance to real or actual working code is purely coincidental.
Updated examples for Drupal 7.x
The examples on this page seem to be for Drupal 6, and are not working with Drupal 7 and the latest dev versions of chart (7.x-1.1+12-dev) and google_analytics_reports (7.x-3.x-dev) modules. Here are the updated examples for Drupal 7. Where changes have been made, I have made comments starting with "UPDATED".
Updated examples for Drupal 7.x
Hello, thanks for the updated
Hello, thanks for the updated examples, but were do I type this code ?
You can output it in a page
You can output it in a page callback which you call using hook_menu(), or in a function generating markup for a block, called using the pair of hooks hook_block_info() and hook_block_view(). All this would be added in a module. Hope that helps :)
More changes now
There are even more changes now that havn't been reflected in the docs. The function to get report data is no longer
google_analytics_api_report_data()
. Now it isgoogle_analytics_reports_api_report_data()
. I'm sure there will be others too, but this is the first one I encountered.Documentation
imho there is a little lack of documentation.
i like the views integration cause i'm more the click guy ;)
can someone confirm if the stuff below is really working as i'm thinking?
created block via views
Fields: Time Dimensions: ga:date and Page Tracking Metrics: ga:pageviews
Filter: Google Analytics: Start/End date of report
Sort: Time Dimensions: ga:date (aufsteigend)
Had some trouble to get this block working for the actual page and ended up with this as contextual filter:
Page Tracking Dimensions: ga:pagePath
with return request_uri() . ';ga:pagePath=~' . request_uri() . '(#.*)?$'; as "Provide Default Value"
only using request_uri etc.. to return something link ga:pagePath=@/path which returns also subpaths. =@ only checks for containing substring. by this way "/path1/path" would also be checked by "/path1" . so extending it with the rest of the line above (regular expression) combines the filters. the views integration always sets the filter to "ga:pagePath=@" So I think combination matches the current url.
sorry if i'm posting this at wrong position. but i think it's more documentation than an issue. Maybe there should be a subpage called "My freaky GAR-Views-Setup" or so
Thank you for this module and explanation
Thank you for this module and explanation
possible to automate an email report?
I've been investigating solutions that generate email Analytics reports: https://briefmetrics.com and https://www.measureful.com/ to name a few.
I was curious if it's possible to have Drupal email "prettified" Analytics report?