1. Take notes.
Wow, this one seems obvious, but I thought I would put it anyways. If you take notes then you should be paying attention. However, plenty of people taking notes have trouble focusing, because they drift off during diferent boring parts. Try taking detailed notes with questions in the margins and small summaries. This will help you do something active almost the entirety of the lecture so you don't get bored and maintain focus.
2. Find a word your professor says a lot and tally every time he says it.
I once had a professor who said the phrase "as I said" over and over again. I would tally every time she said this phrase and in a 50 minute lecture, she would say it over 100 times. This was the only way I could follow what she was saying. However, be careful, if the professor catches you it can be awkward. Although she stopped saying that phrase after she caught me.
3. Music.
If you really struggle with listening, try asking the professor if you can listen to music during the lecture. This may seem counterproductive, but having one earbud in with quiet music can really help you focus. Especially if you just search on Youtube for focus music and play that. Make sure to ask your professor first so they don't try to rip your earbuds out.
4. Doodle.
I love to draw in class. In fact every page of my notes is filled with little doodles. When I'm mindlessly doodling I can actually focus, so even though my page of notes looks like a mess I actually know exactly what's going on. Perhaps it's worth the trade off for you as well.
5. Sit up straight.
This might seem weird, but if you're slouched over your mind is thinking sleep time. If you sit up straight and force yourself to look like you're paying attention, chances are it will be a lot easier to actually pay attention.
6. Before class - sleep and caffeine.
The biggest factor in focus is what you do before the class. If you haven't slept, eaten breakfast and are still a little bit drunk chances are you'll have trouble focusing. Eat a protein rich breakfast after getting at least eight hours, and think about getting in some of that sweet caffeine to ready yourself for class time.
7. Build the habit of concentration.
Whenever you are in class and you find yourself spacing out, be aware of that and immediately refocus. Don't give yourself time to daydream or stare off. Simply thinking about how you need to focus and being aware that you tend to drift off, will allow you to watch yourself and be aware of your own actions. This will allow you to build strong habits of concentration.