I took it periodically for around a year for insomnia. Didn't perceive that it worked well. Was given restoril to try and it seemed this might have worked marginally better, but my perception was possibly placebo, since I knew before hand that "it was supposed to work better". Stopped taking both as I wasn't satisfied with either.
Never had luck with melatonin until the brand I buy started adding vitamin B6 to its formula. It seems to work well (better than either of the two pharmaceuticals) and coincidentally I'm buying more tomorrow to try and fix my recent sleep issue.
FYI, read over the years that more is not better with melatonin. Also, I read some claims that melatonin is best taken at sundown not at bed time, since apparently the body releases melatonin naturally at sundown.
Make sure you read about sleep hygiene. Might want to try meditating in bed as soon as your ready for sleep. I've learned some meditation techniques that work great for myself. My meditation strategy always makes me fall asleep fast.
If you have problems staying asleep try eating a small protein/fat snack before bed. Many people who wake up and can't fall back asleep have problems with low blood sugar during sleep, apparently. Recommend a cup of full fat cottage cheese before bed, or a handful of nuts.