Well first off running around town trying to see your ex and 'accidentally' bumping into them wherever you know they will be hanging out, will usually not work. So if that's what you're doing as you wonder “how do I get my ex back?” then it's time to change that now.
If the breakup has been a particularly rough one, then you're going to need to give both yourself and your ex some time to get over that before you even attempt to make a real move to make up with them and win them back.
Take yourself out of that breakup drama by distracting yourself and occupying yourself with other things. This might sound like you're actually avoiding the issue of the breakup, but you cannot make sound and rational decisions if you're still emotionally red raw from what was said or done by you or your ex in the heat of the moment.
You could take a class, take a trip or get fit! Anything that is going to take you out of just sitting home and fixating on your ex. Truthfully, doing the latter is a surefire way to make the wrong decisions and lose your ex for good.
As you're taking some time out from your ex, it is a good idea to think about what went wrong and what role you played in the break down of the relationship. This is not necessarily to attribute blame, but instead to figure out what you need to do to make sure that you know the answer to your question “how do I get my ex back?” Because as sure as eggs is eggs, if you sincerely want to find a way back with your ex, then you're going to have to come up with a reason for your ex to take you back and that means having a plan to change any 'bad' behavior that you exhibited to help cause the breakup.
It really is that simple, give yourself some time to sort out your thoughts, figure out your role in the breakup and then approach your ex.