If your heart is racing, it sounds like it could be some kind of stress or anxiety that's keeping you awake. In normal pre-sleep conditions, your heart beat should drop to resting heart beat rate, 70 - 80 beats per minute for an adult, not racing.
Is it is anxiety, maybe speak to your doctor, who can help in loads of different ways to help you unwind.
Stress and anxiety have loads of different ways in surfacing and inability to sleep is one of the most common.
Personally, I have a genetic condition which means I only ever sleep for 4 hours absolute tops. It's all to do with high frequency brainwaves and means I am actually physically unable to sleep more than that.
However, it's not a disorder where I need sleep and can't get it, it's a disorder where my brain and body don't actually require any more than the 4 hours.
I can't remember the last time I actually felt tired. Sometimes I am physically tired if I've had a strenous day, but a relax in a chair for half an hour and I'm raring to go again.
All in all though, I think it's a good thing because then I get to sit up late and surf the internet for hours and hours

Anyway, back to your topic.....
For a great relaxation technique whilst laying waiting to nod off, try this.
Lay in a comfrotable position on your back with arms and legs straight.
Now think about your toes. Physically tell your toes that they are relaxed and untense the muscles in just your toes until you can feel that only your toes are relaxed.
Next think about the area between your toes up to your heel. Again, physically relax just this little area.
Once your feet are fully relaxed and completely without stress, think about the area from heels to mid calf. Relax this.
Move steadily up your body, relaxing it bit by bit. Work on areas in this order:
Toes
Toes to heel
Heel to mid calf
Mid calf to knee
Inner and outer thighs
Hips
Front pelvis
Buttocks
Small of back
Stomach
Waist
Spine
Sides of torso
Rib cade
Chest
Fingers
Hands
Wrists
Forearms up to elbow
Elbows
Top of arms
Shoulders
Neck
By this time, you have physically let go of every area of your body and told it that it has relaxed and let any tension go in the seperate areas.
Next thing is to relax your chin
Then mouth
Then cheeks
Then forehead
Then ears (yes ears)
Then your scalp
Now you are fully relaxed and have let go of every muscle and should be pretty relaxed and un-tensed.
Now lay still as you can and just start to think about something really really nice and relaxing, whatever makes you relaxed, whether that is imagining you're near the ocean or something else. The thoughts shouldn't involve any movement, just laying, so it would be laying by the ocean or laying in a field etc.
Hopefully, at this point, you area fully unwound and sleep will come to you.
This is a technique taught to me in a sleep clinic when I was looking for ways to sleep more - until I actually accepted I didn't need the sleep.
The trick is to not move on to the next area until you have fully relaxed the previous area.
It might take a few seconds or a minute to relax each bit but never move to the next until you're ready.
Hope this helps.