Code in boilerplate places tracking code in a separate file using code splitting tech via webpack.
We can see the init function in analytics/base.js is executed after module get loaded.
init() {
// Initialize the command queue in case analytics.js hasn't loaded yet.
window.ga = window.ga || ((...args) => (ga.q = ga.q || []).push(args));
}
After async load module, other code(main logic of the website) is also executed. At the moment(init function in analytics/base.js hasn't been executed), if we trigger ga in window, it will be undefined.
Here is maybe a possible solution
Maybe we should mv window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date; to index.html ?
Firstly, thank you for this amazing library.
I have a question and hope get some suggestions.
Code in boilerplate places tracking code in a separate file using code splitting tech via webpack. We can see the
init
function inanalytics/base.js
is executed after module get loaded.After async load module, other code(main logic of the website) is also executed. At the moment(
init
function inanalytics/base.js
hasn't been executed), if we trigger ga in window, it will beundefined
.Maybe we should mv
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
toindex.html
?