For my dog, it usually seems to be a sign of being happy. She wags her tail if someone says her name, or if someone asks ,"Do you want to go for a walk?" or "Do you want a cookie?" .... but it may also be to ward off alien spirits.

a wagging tail (I believe) is excitement....on that same note...it doesn't mean the pooch is friendly...observe the entire body language to get a better understanding. Oh and the tail is also an alien swatter (duh!)