Last active
August 29, 2015 14:06
-
-
Save foru17/20f34f5fdde1a06dca2e to your computer and use it in GitHub Desktop.
百度统计和谷歌统计的调用方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 百度统计 | |
* 需要放在<head></head> | |
*/ | |
<script> | |
var _hmt = _hmt || []; | |
(function() { | |
var hm = document.createElement("script"); | |
hm.type = 'text/javascript'; | |
hm.async = true; | |
hm.src = "//hm.baidu.com/hm.js?7d692af11a76cb357f8723b544e7e222"; | |
var s = document.getElementsByTagName("script")[0]; | |
s.parentNode.insertBefore(hm, s); | |
})(); | |
</script> | |
<script> | |
try { | |
_hmt.push(['_trackEvent', 'bdoctor_android_share_weibo_sina_'+url_id, 'click', 'bdoctor_android_share_weibo_sina_'+url_id, '1']); | |
} catch(e) {} | |
</script> | |
/* | |
* 谷歌统计 | |
* 需要放在</body>前 | |
*/ | |
<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','//www.google-analytics.com/analytics.js','ga'); | |
ga('create', 'UA-40488675-2', 'cmcm.com'); | |
ga('send', 'pageview'); | |
</script> | |
<script> | |
try { | |
ga('send', 'event', 'bd_android_zh_viewed_time', 'click', 'bd_android_zh_viewed_time_'+url_id+'_30min_plus',1); | |
} catch(e) {} | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment