To receive a windowgram when one of your friends logs in, s/he must be announcing his login and you must be able to receive it. All you have to do is create a file in your home directory and name it '.anyone'. In this file include a list, 1 per line, of usernames of people from whom you want to receive login notification.
Then to receive these notifications, run the program 'znol'. This program will read your .anyone file and subscribe you to the appropriate messages.
The tricky part is that the people you are interested in must set their exposure such that they allow notifications to be sent when they log in or out. This is not set by default. The person must set their exposure to be realm-announced or higher. For more information on "exposure", see "How do I prevent other users from locating me?".