Tracking Blog Visits
Sep 19th, 2007 by yigber
I have an experimental blog on Blogger.com and I was curious to know how users find the posts. In other words - what’s the Referrer set to when they come in ?
Problem is, I don’t own blogpsot.com yet and therefor don’t have access to the raw log files or any other analytics data they have.
So instead I placed this snippet of javascript code into the post and now I have night vision…
Here’s how to do it: Edit your post… then hit to the code tab and finally, paste in the code, preferably in the beginning of the post.
Now you’ve got vision too….
Here’s the code snippet again:
<script defer="true">document.createElement("IMG").setAttribute("src","http://MYSITE/?from=XXX&src="+escape(document.referrer));</script>
Don’t touch the DEFER tag option. Do replace MYSITE with something you own or let me know and I’ll help you with that. Change XXX to be whatever you want to help you remember where you placed this beacon… Oh, and don’t add spaces or line breaks in the <script> block or the wysiwyg editor will put in <br/> tags in your javascript that will kill it.
Of course, more code can be placed there. I only wanted the document.referrer value.
This code will probably work well on other blog platforms that allow javascript. Sometime ago you had to hack a little to do it but nowadays you don’t need any of that. Just put it in.
Unfortunately, javascript can be used maliciously so some blogging platforms like Wordpress.com don’t allow it.
Leave a Reply
You must be logged in to post a comment.