A fairly commonsense article from HomeZada:
By practicing proper fence etiquette, you may be able to save yourself fence-related hassles and headaches down the road. With that in mind, here are some important tips to remember:
1. Tell your neighbors about the fence ahead of time. While of course it’s kind to let your neighbors know you’re about to put up a fence along your property, the bigger reason you might want to bring it up is to double-check that you understand your property boundaries. If you should accidentally assume your yard ends where it doesn’t, for example, you could wind up putting your fence on your neighbor’s land — and therefore having to take it down to start over again later. Look at your property drawing from its survey with your neighbor or, if you don’t have a drawing, hire a surveyor to create one.
Read the rest of the article here.
Splitting the cost of the fence the the adjoining neighbor is also a possibility. A good article about some of the factors involved can be read in this article at SFGate.com.