我正在从 SegmentIO 切换到他们的开源版本。我将此博客文章用作指南,但它没有跟踪。任何人都看到此代码的问题:
window.analytics || (window.analytics = []);
window.analytics.methods = ['identify', 'track', 'trackLink', 'trackForm', 'trackClick', 'trackSubmit', 'page', 'pageview', 'ab', 'alias', 'ready', 'group', 'on', 'once', 'off'];
window.analytics.factory = function (method) {
return function () {
var args = Array.prototype.slice.call(arguments);
args.unshift(method);
window.analytics.push(args);
return window.analytics;
};
};
for (var i = 0; i < window.analytics.methods.length; i++) {
var method = window.analytics.methods[i];
window.analytics[method] = window.analytics.factory(method);
}
analytics.load = function(callback) {
var script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.src = 'https://assets.gonegreenstore.com.s3.amazonaws.com/js/analytics.min.js';
script.addEventListener('load', function (e) {
if(typeof callback === 'function') {
callback(e);
}
}, false);
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(script, firstScript);
};
// Continues from above
analytics.load(function () {
analytics.initialize({
'Google Analytics': {
trackingId: 'UA-40148609-3'
}
});
});
analytics.page();