In this tutorial I will outline how I managed to set up Google Analytics Reports with the Aegir hostmaster system (i.e. give each site an extra tab with Google Analytics summary reports).

Requirements:

  • Aegir 3.x hostmaster with the following additional modules:
  • Google Analytics account with a distinct property ID configured for each Aegir site.
  • You need to configure a web application for the Google Analytics API (see instructions for Google Analytics Reports).

Steps:

  1. Install the required modules on Aegir hostmaster site
  2. For each site, click the tab "variables" and set the variable google_analytics_reports_api_profile_id to the profile ID provided by the Analytics API (note that this is not the same as the property ID!)
  3. Edit the view called Google Analytics Reports Summary (Google Analytics)
  4. Change the path to node/%/google-analytics-reports/summary
  5. Click "menu" and change to "menu tab" and change menu to "navigation".
  6. Add a new contextual filter for Google Analytics: Profile ID
  7. WHEN THE FILTER VALUE IS NOT IN THE URL: Display "Access Denied"
  8. WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED: Specify the following validation with PHP code:
    $vars = hosting_variables_get_site_variables($argument);
    $handler->argument = isset($vars['google_analytics_reports_api_profile_id']) ? $vars['google_analytics_reports_api_profile_id'] : NULL;
    return isset($handler->argument);
    

Contextual filter configuration for Google Analytics Reports
That's it, you should now have an extra tab for each site with Google Analytics summaries!

Additional hint: if you want the correct urls for the "top pages" view, just add the "hostname" field and then for "page title" change the link in the rewrite rule to http://[hostname][pagePath].

AttachmentSize
analytics.png28.61 KB