I got asked this question recently and here's my thoughts
1) Remove ALL distractions in your room - Main one being your phone, Throw it outside your room. Make sure no notifications bug you, don't check social media on your computer. Once you get out of focus from a total separate task it takes time to get focused again (All the momentum lost). This is the main one, if there's no distraction then focus comes easier
2) Get bored - Before starting the class just sit on a chair for 5 minutes and do nothing, stare at a blank wall. Your mind doesn't want to be bored so it'll prefer listening to the online classes more than sitting down and doing nothing
3) Listen to some white noise - While you're in your lectures play some white noise from youtube and put it on the lowest volume you can. White noise can help you stay focused
4) Visual Focus follows Mental Focus - Before you start your lecture, pick a spot on the screen - Ex place the Adobe Icon on the middle of your desktop and stare at it for a minute. After doing this for a minute it primes your mind to be focused. (Your eyes are literally an extension of your brain)
5) Expect the beginning to suck - It takes some ramp up to get into deep focus so don't judge yourself in the beginning if it doesn't quite feel right. Expect it to suck for a bit and embrace it. Also thoughts and shit come up during the lecture so don't expect to be 100% focused the whole time, its okay to dip in and out of focus throughout the session. It's like a muscle and you'll get better at staying focused over time