0

Using Google Analytics Reports module latest version 7.x-3.0-beta2. I wanted to make this module to make requests in non-blocking fashion. Standard drupal makes it blocking fashion, which slows things down.

I started looking into Background Process module, which looks promising. Other option is HTTPRL module, which is similar to Background Process.

Right now I am using AJAX for fetching GA API reporting data, but I feel it's slow, because of how drupal_http_request works (synchronous, blocking way).

Is it possible to integrate non-blocking requests to fetch data from GA API without rewriting excellent Google Analytics Reports module?

  • Just to clarify, you're wanting to make asynchronous HTTP call in the context of an AJAX request? How is the client going to receive data back once the asynchronous HTTP call is finished? – Shawn Conn Aug 27 '15 at 19:38
  • @ShawnConn, basically I mean that GA API calls can be made asynchronously (to speed getting data from external server), and then when all requests are finished - AJAX will spit out the result of it to user. Maby I'm asking too much and misunderstand the concept of asynchronous? – Paulius Pazdrazdys Aug 28 '15 at 8:27
  • I'm trying to clarify exactly what you're asking. If it's what I think it is, you're wanting to make 2 async calls: AJAX to Drupal then Drupal to the GA API. – Shawn Conn Aug 28 '15 at 16:58
  • Yes, that's what I want. Is this possible? – Paulius Pazdrazdys Sep 4 '15 at 16:41
1

This is not possible in the manner that you described. Sure you can make a chain of asynchronous calls, the browser AJAX request to Drupal then Drupal making a non-blocking HTTP request to the GA API. However, your AJAX call won't have data to use.

The Background Process & HTTPRL (check out the project page image) work by the request being one way; they are calling out to a URL that will trigger some background action that doesn't need to communicate back (e.g. some batch job or page crawler cron task). In your case, you need the GA API to communicate back with Drupal then Drupal to communicate back with the browser. There's no getting around that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.