Index: piwik.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/piwik/piwik.module,v
retrieving revision 1.3.4.4
diff -u -r1.3.4.4 piwik.module
--- piwik.module	30 Jan 2011 15:13:41 -0000	1.3.4.4
+++ piwik.module	30 Jan 2011 20:47:40 -0000
@@ -62,6 +62,26 @@
     $piwik_vars = array();
     $url_custom = '';
 
+    // Piwik can show a tree view of page titles that represents the site structure
+    // if setDocumentTitle() provides the page titles as a "/" delimited list.
+    // This may makes it easier to browse through the statistics of page titles
+    // on larger sites.
+    if (variable_get('piwik_page_title_hierarchy', FALSE) == TRUE) {
+      $titles = _piwik_get_hierarchy_titles();
+
+      if (variable_get('piwik_page_title_hierarchy_exclude_home', TRUE)) {
+        // Remove the "Home" item from the titles to flatten the tree view.
+        array_shift($titles);
+      }
+
+      if (!empty($titles)) {
+        // Encode title, at least to keep "/" intact.
+        $titles = array_map('urlencode', $titles);
+
+        $url_custom = drupal_to_js(implode('/', $titles));
+      }
+    }
+
     // Site search tracking support.
     if (module_exists('search') && variable_get('piwik_site_search', FALSE) && arg(0) == 'search' && $keys = search_get_keys()) {
       $url_custom = drupal_to_js(url('search', array('query' => 'query='. $keys)));
@@ -389,3 +409,52 @@
   }
   return $page_match;
 }
+
+/**
+ * Get the page titles trail for the current page.
+ *
+ * Based on menu_get_active_breadcrumb().
+ *
+ * @return array
+ *   All page titles, including current page.
+ */
+function _piwik_get_hierarchy_titles() {
+  $titles = array();
+
+  // No breadcrumb for the front page.
+  if (drupal_is_front_page()) {
+    return $titles;
+  }
+
+  $item = menu_get_item();
+  if (!empty($item['access'])) {
+    $active_trail = menu_get_active_trail();
+
+    // Allow modules to alter the breadcrumb, if possible, as that is much
+    // faster than rebuilding an entirely new active trail.
+    drupal_alter('menu_breadcrumb', $active_trail, $item);
+
+    // Remove the tab root (parent) if the current path links to its parent.
+    // Normally, the tab root link is included in the breadcrumb, as soon as we
+    // are on a local task or any other child link. However, if we are on a
+    // default local task (e.g., node/%/view), then we do not want the tab root
+    // link (e.g., node/%) to appear, as it would be identical to the current
+    // page. Since this behavior also needs to work recursively (i.e., on
+    // default local tasks of default local tasks), and since the last non-task
+    // link in the trail is used as page title (see menu_get_active_title()),
+    // this condition cannot be cleanly integrated into menu_get_active_trail().
+    // menu_get_active_trail() already skips all links that link to their parent
+    // (commonly MENU_DEFAULT_LOCAL_TASK). In order to also hide the parent link
+    // itself, we always remove the last link in the trail, if the current
+    // router item links to its parent.
+    if (($item['type'] & MENU_LINKS_TO_PARENT) == MENU_LINKS_TO_PARENT) {
+      array_pop($active_trail);
+    }
+
+    foreach ($active_trail as $parent) {
+      $titles[] = $parent['title'];
+    }
+  }
+
+  return $titles;
+}
Index: piwik.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/piwik/piwik.install,v
retrieving revision 1.3.4.3
diff -u -r1.3.4.3 piwik.install
--- piwik.install	30 Jan 2011 13:42:49 -0000	1.3.4.3
+++ piwik.install	30 Jan 2011 20:47:40 -0000
@@ -32,6 +32,8 @@
   variable_del('piwik_codesnippet_after');
   variable_del('piwik_js_scope');
   variable_del('piwik_last_cache');
+  variable_del('piwik_page_title_hierarchy');
+  variable_del('piwik_page_title_hierarchy_exclude_home');
   variable_del('piwik_pages');
   variable_del('piwik_roles');
   variable_del('piwik_site_id');
Index: piwik.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/piwik/piwik.admin.inc,v
retrieving revision 1.3.4.3
diff -u -r1.3.4.3 piwik.admin.inc
--- piwik.admin.inc	30 Jan 2011 13:42:49 -0000	1.3.4.3
+++ piwik.admin.inc	30 Jan 2011 20:47:40 -0000
@@ -142,6 +142,27 @@
     '#maxlength' => 255,
   );
 
+  // Piwik page title tree view settings.
+  $form['page_title_hierarchy'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Page titles hierarchy'),
+    '#description' => t('This functionality enables a dynamically expandable tree view of your site page titles in your Piwik statistics. See in Piwik statistics under "Actions" > "Page titles".'),
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE,
+  );
+  $form['page_title_hierarchy']['piwik_page_title_hierarchy'] = array(
+    '#type' => 'checkbox',
+    '#title' => t("Show page titles as hierarchy like breadcrumbs"),
+    '#description' => t('By default Piwik tracks the current page title and shows you a flat list of the most popular titles. This enables a breadcrumbs like tree view.'),
+    '#default_value' => variable_get('piwik_page_title_hierarchy', FALSE),
+  );
+  $form['page_title_hierarchy']['piwik_page_title_hierarchy_exclude_home'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Hide home page from hierarchy'),
+    '#description' => t('If enabled, the "Home" item will be removed from the hierarchy to flatten the structure in the Piwik statistics. Hits to the home page will still be counted, but for other pages the hierarchy will start at level Home+1.'),
+    '#default_value' => variable_get('piwik_page_title_hierarchy_exclude_home', TRUE),
+  );
+
   // Advanced feature configurations.
   $form['advanced'] = array(
     '#type' => 'fieldset',
