Oh god, insomnia. Evil.
Another really good tip is the yoga style "relax". Concentrate in turn on each body part, repeat the name in your head, and make that bit relax. So "left hand fingers, left wrist, left forearm, left elbow, left arm, left shoulder, neck, etc.
Or, if you are lying there thinking "I SHOULD BE ASLEEP IM SO TIRED" try to remember in minute detail a happy day, or happy event. It needs to be quite distant, so is hard, not something you did last week. So if you went for a lovely walk on holiday last year, try and remember and paint a picture in your mind, so not just we went past the reservoir, but try and remember how deep the water was, was colour the wall was, were there ducks, or geese, what wildflowers were out, when exactly the dalmation went past etc etc. Very good distraction.