Yireo_GoogleTagManager2
Yireo_GoogleTagManager2 copied to clipboard
Huge amount of section requests
Server load seems to be increased in factors since the module is installed. Went through some of the logs, noticing about 3-10% of all traffic are section updates by Yireo GTM2.
I looked into this and noticed that a lot of duplicate data (without changes) are added to the DataLayer by subscribing to cart section updates for refresh.
There might be some improvements that can be made, a lot of data in DataLayer is already available client side in the localStorage (mage-cache-storage -> cart). It seems unnecessary to update currency every time, this can be cached client side. You might be able to reduce section updates to zero, which increases performances a lot.
Any thoughts on this?
(Using latest version of the module)
In the file view/frontend/web/js/generic.js
you can see that the GTM extension only reloads its own section in response to the reloading of other sections (KO observable). If you are seeing a slight increase in traffic, then that's correct. I have tested this myself in numerous environments and there is only a single AJAX call added once the cart data are modified. But 10% shows that something else is perhaps at play. The last time I troubleshooted this, I found a culprit extension that simply didn't understand how to work with KO observables. In short, I can't duplicate the behavior that you are reporting right away and I think this is due to your specific combination of extensions.
As for the section-data that are added to the GTM DataLayer, indeed the website ID, transactionEntity
and currency could be added in another way as well. However, this is not generating any significant overhead because the rest of the section-data is needed anyway.
Extensions (and themes) should NOT depend on the localStorage
data but instead use the customerData
object to fetch data. I understand that you are saying that the data contain similarities, but are they indeed totally equal. The reason why the new section was added, was because the existing customerData
for instance contain formatted values that are invalid for GTM. It could be fixed with ugly hacks and regular expressions, but then still GTM would be depending on reverse hack instead of the original data (as it is now) - and we have been there, done that, and it broke things. The current solution is the right architecture. But it assumes that other extensions are playing ball with the Knockout observables and customerData
API as well. Did you make sure they are?
I'm closing this ticket due to inactivity.
Note that a new version of this Yireo GoogleTagManager (v3) was released with GA4 support, full checkout support and completely event-driven. The issue you were reporting was already fixed somewhere in 2020, but the new architecture also outdates any discussion on this :)