lnklnklnk / ga-bq

Stream raw hit-level Google Analytics data into BigQuery
90 stars 38 forks source link

IE 9 and previous versions - no data to BQ #6

Open cristiano74 opened 8 years ago

cristiano74 commented 8 years ago

Hi, I'm testing your app and it works great on recent browsers, like IE10 and IE11 and latest Firefox and Chrome versions, but I see no results for IE9,IE8 and earlier versions.

I think it is about XHR but I'm not sure...

This JS works for me:


function GaBqPlugin(tracker) {

ga(function(tracker) {
        var originalSendHitTask = tracker.get('sendHitTask');
        tracker.set('sendHitTask', function(model) {
            var payLoad = model.get('hitPayload');
            originalSendHitTask(model);

            if (window.XMLHttpRequest){var gifRequest = new XMLHttpRequest()};
            if (window.ActiveXObject){var gifRequest = new XDomainRequest()};

            var gifPath = "http://[xxx].appspot.com/collect";
            gifRequest.open('get', gifPath + '?' + payLoad, true);
            gifRequest.send();
        });
    });

}
ga('provide', 'gabqplugin', GaBqPlugin);

Hope this helps.

Thanks