It is important if you want to learn that you don't just play online you play regulary against someone in person. If you don't it will be a suprise to you on how different it is. eg. timer
But as you said it is also good to play online as you can analyse moves. See where you went wrong etc. Also with online you can study openings, tactics, and endgame all here at chess.com.
Overall I prefer playing chess.com at the moment because it helps me improve a lot. ( as i am studying quite a bit at the moment)
Given avaliablity of a board, opponent and time I would choose a real game (ie on a real board with real pieces). It feels more like a real game to me.
However chess.com online games also have great advantages also;
What do you prefer?