I'm changing google analytics for google tag manager on an existing website. This website also uses google e-commerce, so I have a few custom ga()
calls related to the e-commerce being done on some pages.
The problem is that because the google analytics script loads asynchronously, ga()
is not defined anymore when I'm trying to send some e-commerce related data.
I've found a workaround somewhere:
window['GoogleAnalyticsObject'] = 'ga';
window['ga'] = window['ga'] || function() {
(window['ga'].q = window['ga'].q || []).push(arguments)
};
But, although I've not the "ga is not defined" problem anymore, it still doesn't work.
I don't see anything on the google dashboard. I also don't see anything on the debugging messages (in the developer console).
What seems to be happening is that the GA script loaded with GMT is not using these variables I've set but I'm not sure how to fix it or if it is even possible to keep using my ga()
calls with GMT.
I know that I can do it with dataLayer
but I'm trying to avoid to rewrite a bunch of working code just for this.