1
我想爲當前在本地主機上運行的Angular SPA實施Google分析。我試圖將谷歌跟蹤Js代碼複製到Angular SPA中的每個視圖中。但我不認爲它確實有效。實施Google Analytics for Angular1.5應用
這是實施Google Analytics(分析)的正確方法,或者最新的方法是正確的嗎?
<div class="background">
<div class="container">
<h2 class="page-title">{{'contact-name' | translate}}</h2>
</div>
</div>
<script>
(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', 'UA-XXXXXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
謝謝,我會嘗試。我目前正在我的本地機器上運行我的應用程序,並在localhost:3000上運行。如果我在設置localhost:3000以外的地方時使用URL,我會得到GA中的任何結果嗎?因爲localhost在URL處無效。 – Varun
我發現這個職位,以幫助您開始:http://stackoverflow.com/questions/30581916/test-google-analytics-on-localhost –
嘿,幫助,謝謝。如果您有任何關於如何將Autotrack用於單頁應用程序的小代碼片段,您可以分享嗎?我非常困惑在哪裏實施跟蹤代碼片段。 – Varun