You are here

function _google_analytics_reports_path_filter in Google Analytics Reports 7

Same name and namespace in other branches
  1. 6 google_analytics_reports/google_analytics_reports.module \_google_analytics_reports_path_filter()
5 calls to _google_analytics_reports_path_filter()
google_analytics_reports_path_mini_build in google_analytics_reports/google_analytics_reports.blocks.inc
Generates a block with the current page statistics.
_google_analytics_reports_detail_stats in google_analytics_reports/google_analytics_reports.pages.inc
Retrieves content detail stats.
_google_analytics_reports_pageviews in google_analytics_reports/google_analytics_reports.pages.inc
Renders an img element with a chart of the number of pageviews over the past 30 days.
_google_analytics_reports_top_keywords in google_analytics_reports/google_analytics_reports.pages.inc
Retrieves top keywords.
_google_analytics_reports_top_referrals in google_analytics_reports/google_analytics_reports.pages.inc
Retrieves top referrals.

File

google_analytics_reports/google_analytics_reports.module, line 119
Front-end interfaces that use the Google Analytics API module.

Code

function _google_analytics_reports_path_filter($path) {

  // Decode urls, that might appear due to browsers particularities.
  $path = urldecode($path);

  // Google Analytics regex filters have a limit of 32 characters. Therefore we
  // can't simply create one filter per pagePath. Instead we are going too do a
  // "contains substring" match on the path, and then take as many of the ending
  // characters paired with ([?#].*)?$.
  // Use 100 character maximum to allow some room for escaping regex metacharacters.
  if (strlen($path) <= 121) {
    $filter = 'ga:pagePath=~^' . preg_quote($path) . '(#.*)?$';
  }
  else {
    $filter = 'ga:pagePath=@' . $path . ';ga:pagePath=~' . preg_quote(substr($path, -100)) . '(#.*)?$';
  }
  return $filter;
}