1
AngularJS 앱에 Google Analytics 코드를 추가하고 싶습니다.AngularJS with Google Analytics
저는 Ruby On Rails를 백엔드 프레임 워크로 사용하고 있습니다. AngularJS application.html.erb
Rails 파일은 첫 번째 요청시에만로드됩니다.
그래서 Google Analytics 코드를 viewcontentLoad
이벤트에 넣습니다.
$rootScope.$on('$viewContentLoaded', function() {
(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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXX-Y', 'auto');
// ga('send', 'pageview');
ga('send', 'pageview', {'page': $location.path()});
});
Google 애널리틱스 코드를 삽입하는 올바른 방법인지는 확실하지 않습니다.
난 그냥 그것을 확인하고 당신에게 도움을 know..Thanks을 드릴 것입니다 : 주석의
하나는 이것이 좋은 그것을 할 방법이 제안합니다. – Catmandu