Excitement or submissiveness can trigger piddling. Both scenarios respond well to being given a displacement activity or task to do. In the case of excitement, the dog has to calm down in order to do the task, while the anxious dog can prove his loyalty in a way that doesn't involve pee.
Why does my dog Piddles all the time?
Why Do Dogs Urinate When Submissive? Dogs that urinate submissively are trying to appease someone they see as "socially dominant" and to escape being punished. Submissive dogs pee when they're greeted, when someone approaches, and when there's a history of rough treatment or punishment after inappropriate peeing.
Will my dog ever stop piddling?
Puppies often outgrow piddling when greeting, but some dogs continue this behavior into adulthood, especially if they are insecure or fearful. Fortunately, if you have a puppy who does this type of greeting or an adult dog with a leaky greeting style, there are some things you can do about it.