Problem:
No data is returned when fetching google analytics reports via ajax (using ajax blocks). Everything works fine when ajax is disabled; however, as the warning mentions, the page load time is very long (40+ seconds). This is expected because we are displaying approximately 5 separate start/end timeframe reports on a single page load (day, yesterday, week, month, year). This is a lot of data being fetched from google on initial page load. Ajax blocks to the rescue! (hopefully)

Troubleshooting:
Ajax blocks module has been enabled and load via ajax set to yes. I have tested the most basic configuration (anonymous user on both cached and uncached pages). Anonymous users have permission to access and view the reports. Again, when load via ajax is set to "no", the statistics load fine (with very long page load times).

Hoping we can get this feature working with ajax blocks!

Thanks for any help or ideas.

Comments

cthshabel created an issue. See original summary.

Plazik’s picture

These blocks do not have statistics or simply not displayed?
Are you using contextual filters in these GA blocks?
Change "Include NOSCRIPT tag with original block content" to "no" also.

cthshabel’s picture

The blocks do not have statistics. They are displayed. The only contextual filter is the "Page Tracking: Page" from the default "Google Analytics Reports Page" view.

After changing "Include NOSCRIPT tag with original block content" to "no", the block still does not have statistics.

Attached is a screnshot to better understand. The first block (original), I load via ajax blocks set to "yes" and "NOSCRIPT" set to "no". The second block (CLONE) is loaded on page load with ajax blocks configuration set to "no".

https://s3.amazonaws.com/veuit/support_issues/Screen+Shot+2015-09-02+at+...

Plazik’s picture

I think this is because contextual filter return current path which is different in ajax request.

cthshabel’s picture

Yes exactly I think this is the issue.

So, what I tried instead of Ajax blocks is using QuickTabs module and using the feature to load the other tabs via Ajax (load only the first tab on page load). Then, the other tabs I use views blocks which allow me to pass a contextual filter parameter to each. I tried to look at the "Page Tracking: Page" contextual filter and determine how to pass this filter correctly. In QuickTabs I need to determine how I can pass the $path correctly to the google analytics reports page block.

I think that should resolve the issue. Unless there's a simpler way to do it through custom module or configuration/patch to this module directly?

Plazik’s picture

Ajax urls in Ajax blocks looks something like this:
ajaxblocks?_=1441261765525&blocks=views-2e471cea8859491b84c00c691114ef5c&path=node/3&nocache=1
where path=node/3 is current page path.
You can create a custom "default argument" plugin for views (see example http://cgit.drupalcode.org/google_analytics_reports/tree/plugins/google_...) which will return a "real" page path.

cthshabel’s picture

@Plazik,

Thanks for the tip; it was enough to get me to figure it out.

After adding my own default argument, I realized the path from ajax blocks was not aliased. This patch in ajax blocks resolved our issue:

https://www.drupal.org/node/2370595

I am setting to fixed; however, it will require the patch to be committed in Ajax blocks.

Thanks a lot for your help and comments! Using with ajax blocks works great.

cthshabel’s picture

Status: Active » Closed (works as designed)