In a recent study published in the Royal Society journal Biology Letters, a team of European researchers trawled through dozens of studies on this elusive behavior to propose two key theories as to why it evolved.

“Many animals have tails and use those tails for moving (e.g., an alligator swimming), balance (e.g., a cat walking along a narrow fence), and removing pests (e.g., a horse swatting flies away from its body),” Silvia Leonetti, the study’s first author and research assistant in comparative bioacoustics at the Max Planck Institute for Psycholinguistics, told Newsweek. “But those examples contrast with domestic dogs, who seem to use their tails primarily for communication, rather than any other function.”

Photo of a happy terrier wagging its tail. Why this behavior evolved is somewhat of a mystery. Upyanose/Getty

When a dog is given a stimulus associated with a positive emotion, such as being greeted by its owner, it tends to wag its tail more towards the right. However, when exposed to stimuli that might elicit withdrawal, such as an unfamiliar human or when confronted with a more dominant dog, they tend to wag more towards the left.

Interestingly, dogs can perceive these asymmetries in other dogs and even tail-wagging robots, adding further evidence of some sort of communication role for this behavior.

Despite these nuances, tail wagging is frequently associated with some sort of arousal, be that positive or negative. This, the authors write, suggests it may be correlated with arousal-related hormones and neurotransmitters in the dogs’ bodies. They cited indirect evidence linking oxytocin, the “love” hormone, and tail wagging, especially when dogs are reunited with their owners.

There may also be an association between tail wagging and the stress hormone cortisol, although studies on this hormone have been less conclusive due to variability between different breeds and life histories.

When compared to their nearest neighbors, the wolves, dogs wag their tails significantly more often, and from a much earlier age. This suggests that their wagging behavior evolved in line with their domestication by humans, which lends support to the theory that tail wagging may have arisen to allow these animals to communicate with their human masters.

“One study found that during food denial situations, dogs wagged their tails more when a human was present versus not, suggesting that tail wagging may also function as a requesting signal,” the authors write.

But this evolution may not have been intentional. For example, the authors suggest that tail wagging may have arisen as a by-product of another selected trait, like tameness or friendliness. And this does appear to have been the case in one long-term experiment with silver foxes, designed to replicate the mammalian domestication process in real time.

In this study, a cohort of silver foxes was bred over 40 generations and selected to have traits like tamability and docility—similar to the traits that would have likely been selected for in the ancestors of the modern dog. Tail wagging was not directly selected for, but over time, the tamed foxes also began to show a dog-like tail-wagging behavior.

“Based on this, we hypothesize that the domestication process may have led to changes at the anatomical and behavioral level that altered tail wagging behavior in dogs,” the authors write.

Alternatively, they hypothesize that humans may have actively selected for the behavior, perhaps due to an unconscious attraction towards rhythmic behavior and our innate ability to spot patterns in such rhythms. However, while these theories might explain why tail wagging evolved, there are still many questions left unanswered.

“We are just scratching the surface,” Andrea Ravignani, the study’s senior author, told Newsweek.

Questions remain over how dogs can control this behavior, how well they can decipher the meanings of this wagging among other dogs, and how shorter-tailed breeds may be held back by a reduced ability to perform this behavior.

“We echo the concerns of other researchers that these procedures may impair the communicative repertoire of an animal (although this should be empirically tested by comparing breeds) and reduce how well a dog can express its feelings and communicate,” Ravignani said.

More in-depth studies must be done to confirm these evolutionary origins and answer these remaining questions, but the team hopes that their review will spur continued research on the subject.

“Having highlighted the complexity of this behavior and the importance of studying all the different components that constitute it, we invite our colleagues to continue using and developing advanced and non-invasive technologies to address a multidisciplinary study not only of dog behavior but also of dog-dog and dog-human interactions,” Leonetti said.