Skip to content

Instantly share code, notes, and snippets.

@firedfox
Created August 9, 2012 05:53
Show Gist options
  • Save firedfox/3301451 to your computer and use it in GitHub Desktop.
Save firedfox/3301451 to your computer and use it in GitHub Desktop.
analytics code for tieba
var _hmt = _hmt || [];
$(function () {
$.getJSON("/f/user/json_userinfo?_=" + new Date().getTime(), function (response) {
var userInfo = response.data;
if (userInfo.is_login) {
console.log("login")
_hmt.push(['_setCustomVar', 1, 'login', 1]);
} else {
console.log("not_login");
_hmt.push(['_setCustomVar', 1, 'login', 0]);
}
var hm = document.createElement("script");
hm.src = ("https:" == document.location.protocol ? "https:" : "http:") + "//hm.baidu.com/h.js?dfc44cb6724d4d64aff0189edd0b4d95";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s);
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment