Try talking to the owner of the dog and let him/her know about the problem that you are facing. Do not be aggressive and maintain a friendly approach for a favourable outcome of your discussion because it is impossible for your neighbour to not know what their dog is actually doing. If you accuse him/her for not training the dog properly you might end up rubbing that person the wrong way.
You need to note the times of the day when the dog fouls your yard and then put the sprinklers on the moment the dog enters your yard. Dogs do not like to get wet so you will probably succeed in stopping the animal.
You can also use some commercially available repellents, which can be very effective in stopping the dogs from fouling the yard. However, if you have a big yard, then the repellents will not be able to cover the whole area. The repellents are available in various forms but it is better that you use sprays as they are deterrents in both taste and smell.
If there are any community laws in your area regarding cleaning up after your dog then you need to report it to the concerned authorities. However, only do this after your neighbour refuses to do anything about the problem. After you report your neighbour for the violation of community laws, you might have a bitter neighbourly relationship ahead.
Never beat the dog because that is cruelty to animals, you need to keep in mind that the dog is only doing what comes naturally. So the blame should not be on the animal, instead the owner needs to spend some time in training their dogs. You should devise means to discourage the dog from entering and fouling your yard. Once you have perfected the safest method, your yard will be clean and free from any future mess.