If there is no physical medical reason (such as a UTI) then I beleive your dog is marking his/her territory when you have visitors. A lot of this may stem from your dog's position in the family has been unintentionally elevated to alpha status or because you dog has a confidence issue. Either behavior can be changed with some work and training. Here is a good article on "marking" that another YT member posted on another thread.
Marking: Understanding It, Stopping It