Permalink
Browse files

feat(SEO): baidu tongji pv

* 解决前端路由pv无法统计的问题
* http://tongji.baidu.com/open/api/more?p=ref_trackPageview
  • Loading branch information...
ICELI committed May 12, 2017
1 parent cbcf972 commit 705a0379210e00e4193e4480f6c212594163a3e3
Showing with 14 additions and 1 deletion.
  1. +10 −0 index.html
  2. +4 −1 src/app.js
View
@@ -33,6 +33,16 @@
<!-- SEO脚本 百度统计代码 -->
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?92de84cc51276413aeb4fa8d45b3b14c";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>
View
@@ -82,12 +82,15 @@ app.config(function ($provide, $controllerProvider, $httpProvider, $locationProv
});
app.run(function ($rootScope, $log, $state, Util, Login, Api, Auth) {
app.run(function ($rootScope, $log, $state, $location, Util, Login, Api, Auth) {
$rootScope.show = false;
$rootScope.$state = $state;
// 路由切换成功
// , toParams, formState, formParams, options
$rootScope.$on('$stateChangeSuccess', function () {
// 百度统计pv量
_hmt.push(['_trackPageview', $location.path()]);
$log.log('app run $stateChangeSuccess');
$rootScope.show = true;
Login.checkHasLogin().then(function (data) {

0 comments on commit 705a037

Please sign in to comment.