The fact that the dog only does it for the owner is a submissive thing.
I have a German Shepard who when anyone else comes up, she’ll wag her tail and be generally sweet, but when one of the family comes up, she puts her ears back and her tail down, and if we make cutesy noises, she pees. D: