Instantly share code, notes, and snippets.

Embed
What would you like to do?
Google Analytics: hitCallback
var likeBtn = document.getElementById('like');
likeBtn.addEventListener('click', function() {
if (typeof(ga.getAll) == 'function') {
ga('send', 'event', {
'eventCategory': 'engagement',
'eventAction': 'like',
'eventLabel': document.title,
'eventValue': 1,
'hitCallback': function () {
likeBtn.innerHTML = '<i class="fa fa-thumbs-up"></i> 已赞';
}
});
} else {
likeBtn.innerHTML = '<i class="fa fa-thumbs-up"></i> 出错了';
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment