Tracking a page in an Ajax Popover from Google Analytics

依然范特西╮ 提交于 2019-12-24 16:46:02

问题


I am looking to track a Pop-Over page that appears when the forum is submitted at:

http://www.xebra.com/salesAssistance.html

I tried adding the urchin/google analytics code to the page that is displayed in the pop-over window, but whenever I do so the status bar displays "Read http://www.google-analytics.com/" and the entire form page goes blank.

It is important to track the page in the popover because that page is the conversion goal (the page we are trying to direct people to).

How do I stop Google Analytics from destroying my window, while still tracking that a user has been there?


Thank you,
Andrew J. Leer


回答1:


You could separate your google analytics code into two bits:

one that goes on top of the page:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." :"http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
    var pageTracker = _gat._getTracker("#########");
} catch(err) {}
</script>

and the other just before the "end body" tag

<script>
   pageTracker._trackPageview();
</script>

And the call the pageTracker._trackPageview(); method in the ajaxComplete callback of the "pop-up" window.



来源:https://stackoverflow.com/questions/655093/tracking-a-page-in-an-ajax-popover-from-google-analytics

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