Closed tomjrjones closed 1 year ago
Nope. IA is server-side analytics, which means Craft needs to execute on each request. Blitz uses static caching, which bypasses Craft and just serves up the pre-rendered HTML.
@khalwat i believe there are possibilities as long as you don't have nginx or apache render the HTML Blitz puts out. Blitz has a event that is triggered before it renders the HTML, which we've used to send the collected events:
// Send the collected events
Event::on(
CacheRequestService::class,
CacheRequestService::EVENT_AFTER_GET_RESPONSE,
function (ResponseEvent $e) {
InstantAnalytics::$plugin->ga4->addPageViewEvent();
InstantAnalytics::$plugin->ga4->getAnalytics()->sendCollectedEvents();
}
);
We've gotten many events, especially for commerce, to work this way. It would be nice to have some support in the plug-in.
Right, I'm assuming people using Blitz will be using the Nginx / Apache rewrites, because otherwise they lose most of the TTFB benefits of using a static cache.
Hi @khalwat ,
Just wondering if this plugin works with blitz caching? Or will I have to manually add the events within my page templates.
Many Thanks, Tom