简体   繁体   中英

_gaq.push not working in google analytics

ok, so, I have been trying to make _gaq.push work since so long now.

And my corresponding code is as below.

 var ext_id = localStorage.ext_id; var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-xxxxx-xx']); _gaq.push(['_trackPageview']); //console.log(_gaq); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = chrome.extension.getURL('js/ga.js'); //uncomment this //ga.src = "js/ga.js" // ga.src = 'https://ssl.google-analytics.com/ga.js'; document.head.append(ga); // make it head // var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); // comment this out })(); chrome.runtime.onConnect.addListener(function(port) { console.assert(port.name == "google-analytics"); port.onMessage.addListener(function(response) { console.log("Message Passing with response",response.category,response.action, response); // _gaq.push(['_gat._forceSSL']); // remove this _gaq.push(['_trackEvent', response.category, response.action,ext_id]); // trouble shoot this console.log(_gaq, "sending this"); }); }); 

so, the above will be run when there's no activity on the payments page for more than 1 second. And its triggering properly, ie its executing after 1 second of inactivity on payments page. But, but _gaq.push is showing no trace in the network tab, to make it more obscure, I'm not even getting any error. Can someone pls tell me what I could possibly be doing wrong?

The gaq.push looks fine and should work.

I think your ga.js library is not loading. Maybe since getURL is deprecated? https://developer.chrome.com/extensions/extension#method-getURL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM