Using Ajax blocks to load Google Reports is important because it saves initial page load time. When loading multiple reports, it can slow down page load dramatically.

I am using Quicktabs module to display each report on it's own tab; unfortunately, the request_uri() is not set correctly when using quicktabs because the request is a specific quicktabs request. Note: this is only when loading the tabs via ajax. I was hoping Ajax blocks would still work, even when displaying blocks in quicktabs, but the ajax functionality wasn't working. When loaded via quicktabs ajax, the request doesn't contain the original path either.

The workaround I am using is adding a default argument for Page Tracking: Page in contextual filters. Currently, this is in a custom module; however, it may be useful for other's if it is included as another option for the default argument in Google Analytics Reports module?



/**
 * @file
 * Contains current page path argument default plugin.
 */

/**
 * Default argument plugin to use current page path as argument.
 *
 * @ingroup views_argument_default_plugins
 */
class myviewschanges_plugin_argument_default_google_analytics_reports_path extends views_plugin_argument_default {

  /**
   * Get argument.
   */
  public function get_argument() {
    // Decode urls, that might appear due to browsers particularities.
    // Using quicktabs url, getting referer url from request instead of request_uri() which is quicktabs specific

	if (isset($_SERVER['HTTP_REFERER'])) {
		$referer_url = $_SERVER['HTTP_REFERER'];
		$referer_path = parse_url($referer_url, PHP_URL_PATH);
		return $referer_path;
	}
  }
}


This uses the referrer URL. Unfortunately, referer_uri() function is depracated as of Drupal 7?

Please let me know if this sounds like a solid idea?

Thanks!

Comments

cthshabel created an issue. See original summary.

cthshabel’s picture

I should note that this works in my current setup; however, I am not sure this is the best approach.

cthshabel’s picture

Title: Page doesn't have any statistics when loaded via Quicktabs Ajax » Load Google Reports via Quicktabs Ajax