Wagging the tail is not a universal sign of joy: it is an indicator of general excitement, which can precede a bite as well as a game. Its real meaning depends on the height of the tail, the amplitude of the movement and its speed, never on the beating alone.
A language made of nuances
A tail held high, stiff, which vibrates at a small amplitude and high speed signals intense excitement, often linked to a threat or a frustration: this is the signal of a tense dog, potentially ready to bite. Conversely, a low or back-length tail, which sweeps widely and slowly, usually accompanies a relaxed or friendly state. Between the two, all combinations exist, and the context (general posture, ears, gaze) remains essential to interpret the signal correctly.
Research in ethology has also highlighted a right/left asymmetry in tail beating: dogs tend to move more to the right when they perceive a positive stimulus (such as the sight of their owner) and more to the left when faced with a stimulus that they judge to be negative or threatening (such as an unknown and dominant dog). This lateralization would reflect different cerebral activation depending on the hemisphere involved, a phenomenon also observed in other vertebrates for emotional behaviors.
An essential safety point
For the safety of children, it must be remembered that a dog that wags its tail is not necessarily approachable: a high and stiff tail, associated with a body frozen or leaning forward, ears erect, signals tension which can lead to a bite without any prior growling. Learning to observe the animal's entire body, and not just the tail, is the best prevention. If in doubt about a dog's behavior, the advice of a veterinarian or a canine behaviorist remains the most reliable resource.