Using Blogger builtin Google Analytics support

I was wandering around the settings section and found out I can not only turn off sharing on Google+ but also have Google Analytics support from Blogger. I recall I had read it long time ago on Blogger Buzz.

I want it because the pageviews from View will be also tracked. I can not touch the code of View, so this option is very helpful if I want to have complete tracking statistics. I have put View link on top of navigation bar for really long time and I probably lost some data.

I wrote my own Layout template, so it won't work by default in my own layout. It is actually very simple to have it, add the following line before </body>, e.g.
  <b:include data='blog' name='google-analytics'/>
</body>

I also removed the tracking code from my main JavaScript script, so I wouldn't have duplicate data.

This is probably the second of third time I use View mode on Blogger, not only on my blog but entire Blogger blogs. I don't really like View, it looks good and nice, but I am just not a fan of it.

Maybe because it create unique style over different blogs. I like variety, diversity of styles or layouts or designs. Pretty or ugly, doesn't matter. The important thing is the style of the blog's owner. With View, it doesn't reveal of that much.

Since I hardly check the View of my blog. I just realize there are two ads units. One at right side, the other at bottom. I roughly check with FireBug Net tab, I think they are belong to me, my Google AdSense Publisher ID, I believe. (It's long ID, but looks like mine)

As you may know, I put two ad units in my template, so I don't object for the such convenience. Just I don't see any setting options I can adjust size or location for my View. So it probably also a unique setting all over the views, I guess.

Blogger new post preview with Google Analytics?

Updated at 2012-02-25T23:08:40Z: This has nothing to do with Blogger. It seems Google Analytics' tracking script will detect if you hold the account. If you do, then it shows you the interface. Here is a screenshot when I view the homepage of my blog:





When I was writing my previous post, I saw this after I hit preview button:


We found no clickthroughs for this page. Try adjusting the date range or select another page.

You got it perfectly right, Google Analytics! Because it's totally new post, how could you find click? If you do, either your are a fortune teller or something gone haywire.

But I don't mind this show up when I edit my old posts. It would be nice to know some statistics. Only it takes a few seconds to load the Google Analytics frame every time you hit preview button.

Download GAE access log and check geographic location of IPs using MaxMind geoip-python

I need to find an IP whose geographic location is already known from other source. Normally, it’s the other way around, but this situation is different. I will explain in later post.

First, downloading the access log from GAE. It is simple, this is the command I ran:

python google_appengine/appcfg.py --num_days=3 request_logs project/ access.txt

--num_days specified 3 days of logs, the default is the logs of current calendar date, according to the documentation, options of request_logs can be found below in that page.

Next is to find the geographic location by IP address. You need to install MaxMind Python binding with C core on your system. Here is the core snippet I use to generate results:

import GeoIP

#gi = GeoIP.new(GeoIP.GEOIP_MEMORY_CACHE)
gi = GeoIP.open("/usr/share/GeoIP/GeoLiteCity.dat",GeoIP.GEOIP_STANDARD)
gi6 = GeoIP.open("GeoLiteCityv6.dat",GeoIP.GEOIP_STANDARD)

with open('ips.txt') as f:
  for IP in f:
    IP = IP.rstrip('\n')
    if ':' in IP:
      gir = gi6.record_by_addr_v6(IP)
    else:
      gir = gi.record_by_addr(IP)
    print '%s: %s, %s, %s' % (IP, gir['city'], gir['region_name'], gir['country_name'])

GAE accepts both IPv4 and IPv6 connection, so you may want to also to look up for IPv6 address, or you will need to filter out IPv6 addresses and drop them. You can download free city database for IPv6. Note that Python binding version may need to be 1.2.7 for IPv6, I know 1.2.4 does not support IPv6.

Before you run this snippet, you need to process access.txt to have unique IPs:

cut -f 1 -d ' ' access.txt| sort | uniq > ips.txt

On Linux, it’s simple as that, or you can process in Python, I think it’s only need one line.

So, I ran:

script.py | grep '<CITY NAME>'

I got no results, I am sure if the requests were made, it must lies within 3 days. Something is really fishy.

Although I didn’t find that IP, but I wrote this post.

Social networking obstacle

Yesterday, I was watching a stream. The broadcaster received a Twitter following request via Facebook post (or something, not sure what that is called on Facebook). The screen showed the caster clicked on the link to the requester's Twitter page. The next ten or twenty seconds, the viewers watched the caster trying hard to find the "Follow" button to follow which had been under cursor for most of time.

As you could imagine, viewers were laughing so hard as I was, or ROFL or LMAO for short. Even I has stopped using Twitter almost two years ago and the layout has been changed quite a lot, I still could spot that button right away.

Recently, I found out a very interesting fact. Even someone in their sixties, they may be good at using Facebook but not be able to take care of their Windows operating system. They may be tapping like a pro on iPad, having some awesome apps installed by themselves. But never heard of or used RSS feed.

People seem to get used to be in a certain circle or website. For example, the Facebook. They are so used to it and somehow can't have a concept that they can also follow/subscribe to same group of people on other websites. Everything has to be provided or accessed via Facebook. If something is mentioned by someone, some will ask for a link.

Day after day, you will see same people ask for same thing again and again. They never learn to receive the new updates from other website which is the original source. It looks to me as if everything has to be on Facebook and only, or they would be completely unknown to those people.

Do people really have problem using other website which they are not familiar with? Certainly not, just too lazy to click.

I had used Facebook for some time and de/re/activated my account for two times at least. I just couldn't get the idea of Facebook. It's not social, in fact, not really any of social networking websites is real socializing, they are social networking, but not social.

Well, maybe they are not for general purpose, but for people to hook up someone for sexual purpose in my feeling. Nevertheless, it's still possible you can use it to find your high school classmate or long lost friends.

I also tried a few times on Google+, but never got into it, not even tried to add someone to the circles. The more I used these websites, the more I feel it's the sea of messages or posts or updates or whatever you call it.

We are buried in those messages. For me, I am afraid that I may be missing something important, something has real value. Not just that kind of chit-chat or j/k or LOL messages. It's not like I dislike those, life without those will be boring, but I don't want those to mess up with real message, either.

On Google+, you have a slider to filter the amount of messages. I know I definitely wouldn't want to try that because the chance of missing a message. I guess you can make sure someone's message will always be shown, but you never know if you remember to maintain the whitelist. In many case, it's human error of user's. They forget to set or update certain message.

You must be either having a crystal mind or giving no about what you may miss if you want to use social networking correctly, or it will just be obstacle in social life.

Email, phone, and letter are better than those.

XChat Python plugin for monitoring messages

I wrote this Python snippet for XChat:

import os
import xchat


__module_name__ = "xchatmsgmon"
__module_version__ = "0.0.0.1"
__module_description__ = "Python module for monitoring messages"


def on_message(word, word_eol, userdata):

  if '@' in word[2] and \
     xchat.get_info('channel').startswith('#friends') and \
     'y' in word[1]:
    os.system('/usr/bin/mplayer /usr/share/sounds/warning.wav')


xchat.hook_print('Channel Message', on_message)
print "%s loaded." % __module_name__

To load it, run /py load /path/to/script.py or just /py load script.py if you save it at default configuration directory like ~/.xchat2. Run /py unload xchatmsgmon to unload it.

You can check sender’s username in word[0], user’s mode in word[2], and the message is word[1]. After callback function is hooked by xchat.hook_print, all channel messages will be sent to the callback function. But only the messages meet the rules below:

  1. Sent by OP, i.e. mode with @.
  2. Sent to channel name starts with #friends.
  3. With letter y in the message.

If the message meet the rules above, then a command is executed. This is just snippet, so the command may not work on your system. You can use any notification system or play media file with your favorite library. Creating GTK window with red background for ultimate attention. Whatever you want as long as you can code it.

You may also want to hook up the highlight message print event as the issue mentioned here. You can read this xchat-python page, it’s a good place to get started writing about XChat Python binding.

Google Search's Blocked Sites

Yesterday, I was thinking to turn off Personalized Results, so I can see what non-signed in user would see. Don't want to use second browser/private session/etc to because I remember I used to see there is a link below the search result which you can temporarily turn off personalized results, but it has long gone.

I head over to the Search Settings, funny thing is I didn't see such option even a help entry, Turn off personal results, mentioning it. I don't have Web History running but I do have Google+ and I can see those additional results/annotations for social circles. I sometimes see Google Help doesn't help at all because things have changed, but help documentation doesn't get updated.

Anyway, what I saw is Blocking unwanted results, I don't long how long it have been sitting there, but I am glad I finally noticed it!


"You may block up to 500 sites." Oh yeah, that should be enough for me. I tried one and the website was removed from the results immediately.


I don't intent to block spam websites or content farms, those sites could be more the the population of cockroaches in the entire world. I want to block some archive websites as I mentioned in a post about Google Chrome Personal Blocklist Extension.

For those spams, I can only hope Google Search's algorithm will make them never see the light, rusting at the deep dungeon. Don't even think about it, they are rats, not dragon slayer. This is not video game, you nerdy dude! ;)

As for archive type websites, I don't really need to see them when there are original public source, even they are legit in my definition.

I have seen many times, they outrank original source which is never a good thing in my opinion. Besides, for one source, it could be four or more website doing the archiving. That means every five results, there is only one unique content, the only difference is the design/layout and ads.

Back to the blocking setting, you can download the list as text file, but I don't see an option for you to upload. If you really have many entries, it will be easy to maintain on your end with your favorite editor.

How so? Because I wouldn't just let it be simple text of lines of URL. It will be grouped with comments. For example, if the original archive site down, I can uncomment the archive sites group, then upload the temporarily updated list, so I can see those blocked archive sites.

Of course, I will have my custom shell script to generate uploading list text file, comments will be removed from output. Well, you only need one grep, actually.

But that's just how I would like to use it if you can upload. Who knows, we might even have API for this. I only really hope this setting will stay, Google has terminated too many good stuff.

Alright, enough talking, time to put into more action. Gotta add more blocked sites to the list, it's Friday!