The best way to keep your dog in your yard is to address the reasons why he or she is trying to run away. This might mean getting your dog neutered, spending more time with your pet, or making sure that your pet has somewhere safe to hide if he or she gets scared. If you can't fix the behavior, though, you might need to fix the fence itself. A taller fence might be your best bet in some cases, while simply making sure that you add something to the bottom of the fence to prevent digging might be the better choice in other situations.