1/18/14

view count

This is how many unique people have viewed this post:



Here's how to add a counter to another page using JavaScript:

$.ajax({
    url : 'http://view-count.herokuapp.com/view/' +
        encodeURIComponent(location.href),
    xhrFields : { withCredentials: true },
    success : function (count) { alert(count) }
})    

Here's the source code. It uses cookies to track uniqueness. It runs on a free heroku server, and shouldn't be counted on (hehe), but you can run your own server.

Here's the unique view counts for everything the server knows about. Note that if you use this service, your view counts will appear in this list publicly too:



No comments:

Post a Comment