简体   繁体   English

如何在Extjs单页面应用中添加Google Analytics分析事件跟踪?

[英]How to add google analytics event tracking in Extjs Single page App?

I have one single page app built in EXt js (5.1.1) and trying to implement google analytics event tracking for all buttons and clicks 我在EXt js(5.1.1)中构建了一个单页面应用程序,并试图对所有按钮和点击实施Google Analytics分析事件跟踪

Is there any plugin available for this ? 有没有可用的插件? i found some plugin which is jQuery based will this work in EXT js ? 我发现一些基于jQuery的插件会在EXT js中运行吗?

I don't think you need a jQuery plugin, nor a plugin at all for this. 我认为你不需要一个jQuery插件,也不需要插件。

Just use the Universal Analytics Code documented here https://developers.google.com/analytics/devguides/collection/analyticsjs/pages 只需使用此处记录的通用分析代码https://developers.google.com/analytics/devguides/collection/analyticsjs/pages

For example, to send a page view, you just need this line of code 例如,要发送页面视图,您只需要这行代码

ga('send', 'pageview', 'path to your virtual page');

This is what works for us 这对我们有用

<script type="text/javascript">
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
                    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
                m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
    ga('create', "MY-US-CODE-GIES _HERE", 'auto');
    ga('send', 'pageview', {'page': (location.pathname+location.search+location.hash)});

</script>

This only gives path but not the load time. 这只提供路径而不是加载时间。 I still do not have solution for page load time 我仍然没有页面加载时间的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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