简体   繁体   中英

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

Is there any plugin available for this ? i found some plugin which is jQuery based will this work in EXT js ?

I don't think you need a jQuery plugin, nor a plugin at all for this.

Just use the Universal Analytics Code documented here 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

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