Unfortunately, one day he did this and something inside you snapped. You yelled at the pup. For a while you thought this had helped, because he stopped peeing in front of you... but then you found a wet patch behind the sofa and realized he'd become secretive about his bad habits. Now you have an even more difficult problem to solve, because you don't always know where he is and what he's doing.
If only there was a foolproof way to potty train a beagle....
Be aware of the pup's need to empty his bladder regularly, and give him plenty of opportunity to visit the right spot. Then praise and reward the puppy, so that he links toileting outside to nice things. However, be sure any cue words as specific to toileting, so that he doesn't become confused and think that "good" means he is expected to pee. Also, it's also crucial not to punish the puppy when he does soil in the wrong place, since this can actually slow up training.
And finally, while rare, some pups do have medical or anatomical problems which make potty training difficult. If your pup seems slow to catch on, get him checked by a vet.