Event tracking not working

∥☆過路亽.° 提交于 2019-12-11 01:41:58

问题


I am trying to integrate the Google's event tracking on my application using the below script. I can able to see the Events in "Realtime" tab. But I am not able to see the events in "Content" tab.

  var _gaq = _gaq || [];
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAccount', 'XXXXX']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_trackEvent', 'request.fullpath', 'plan_desc', 'plan_code>']);


回答1:


Are you grabbing the script that defines the gaq function?

var _gaq = _gaq || [];
  _gaq.push(['_setDomainName', 'none']);
  _gaq.push(['_setAccount', 'XXXXX']);
  _gaq.push(['_trackPageview']);
  _gaq.push(['_trackEvent', 'request.fullpath', 'plan_desc', 'plan_code>']);
(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

Also, for your event push, are the values you are pushing in supposed to be JS objects? if so, you may want to get rid of the quotation marks.




回答2:


GA takes a certain amount of time before it translates data that you see in real-time into it's other sections.

It might be that if you have only added the code within 48 hours that results are not ready to view yet.




回答3:


I would suggest you trying Google Analytics Debugger extension for Chrome to see if tracking events reach google.

https://chrome.google.com/webstore/detail/google-analytics-debugger/jnkmfdileelhofjcijamephohjechhna?hl=en




回答4:


If you are trying to use Rails variables in the JS, as request.fullpath looks like one you must make sure you are rendering it out in your templating engine. For example, if you are using ERB, you must call it like this...

_gaq.push(['_trackEvent', '<%= request.fullpath %>', 'plan_desc', 'plan_code>']);

Obviously repeat for the other variables, if they aren't Ruby and are plain JS objects, you need to omit the quote marks around them.



来源:https://stackoverflow.com/questions/16060916/event-tracking-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!