Closed indykoning closed 8 months ago
You are absolutely right!
I think we need to create a fake one. But ive asked my GA guy if this is correct.
if ($gaSessionId === null) {
$gaSessionId = random_int((int)1E01, (int)1E010);
$this->logger->info('Google Analytics cookie not found, generated temporary value: ' . $gaSessionId);
}
This would be it then
Merged!
Does this work for you @indykoning ? For us this is working in 2 projects!
I'm seeing a lot of fallback session ids in some of our projects so by the looks of it it is working perfectly! 🚀
Because of https://github.com/elgentos/magento2-serversideanalytics/blob/879f2a95a0177da11d2e3cfec863dc65c7697850/Observer/SendPurchaseEvent.php#L75 Purchase events will no longer be fired at all once the customer placing the order does not have a session id in their cookie.
This is possible because a customer blocks GTM causing their GA id and GA session ids to never be created. Previously this was solved for the GA id by creating a temporary id
https://github.com/elgentos/magento2-serversideanalytics/blob/879f2a95a0177da11d2e3cfec863dc65c7697850/Plugin/SaveGaUserDataToDb.php#L80
However this same process does not exist for the session id
I'm afraid i do not know wether we should send the event with an empty session id or a generated session id