Another way to say "dogs wag their tail when they are happy" is "When dogs are happy, they wag their tail."