Tail wagging is the behavior of the dog observed as its tail moves back and forth in the same plane. Within Canidae, specifically Canis lupus familiaris, the tail plays multiple roles, this can include balance, and communication. It is considered a social signal. The behaviour can be categorized by vigorous movement or slight movement of the tip of the tail. Tail wagging can also occur in circular motions, and when the tail is held at maximum height, neutral height, or between the legs.

Tail wagging can be used as a social signal within species and convey the emotional state of the dog. The tail wagging behavior of a dog may not always be an indication of its friendliness or happiness, as is commonly believed. Though indeed tail wagging can express positive emotions, tail wagging is also an indication of fear, insecurity, challenging of dominance, establishing social relationships, or a warning that the dog may bite. It is also important to consider the way in which the dog wags its tail. Usually positive feelings within a dog are associated with the right side. For instance, if a dog is about to receive a treat, their tail will likely move with a bias towards its right. On the other hand, negative feelings are typically connected with a bias towards its left side. If a dog is being approached by another dog and feels threatened, the dog's tail will usually move more to its left.

More Info: en.wikipedia.org