Playing with a metronome can be a challenge but can help tremendously with achieving proper timing when playing a musical piece as well as refining your ability to maintain the overall tempo throughout the song.
I find that the digital metronomes that allow you to choose from a large number of different beats where you can have the accent beat where it needs to be to establish the proper "groove" for the music - is much easier to adapt to than the old wind up metronomes that only tick tock like a grandfather clock.
What I personally find I must do on a complex timing piece when trying to learn it by using a metronome, is to slow the metronome down to a ridiculously slow tempo. This give me time to think about the next note before the metronome clicks and makes it easy to land my finger on the note at the same time the metronome clicks. Sometimes I will even double the tempo but play at half that speed so I have an in between phantom (not supposed to be there) reference click in between the real clicks. This trick is especially helpful if some notes get played on an off beat.
It also helps to break out the song into small segments - even as small as two measures at a time and gradually add the others until I can play an entire verse.
After you are able to play it at the ridiculously slow tempo, start speeding it up gradually until you are able to play it accurately at the new faster tempo. Repeat this process until you can play full tempo (or faster).
As others have said, counting aloud can be extremely helpful because it helps you connect to the beat in a manner that reflects where you are in each measure and it gives you another auditory cue. And vocalizing aloud helps anchor everything in your brain (similar to the way thinking out loud sometimes helps you process your thoughts). If it's a complex beat where some note occur on an off beat you might have to count "one and uh two and uh three ...." instead of just "one - two - three ....".
Playing with a metronome or click track comes easier to some musicians than others. But with slow deliberate practice, you should be able to master it eventually. If a particular piece proves exceedingly difficult, don't be afraid to play it with a beat that is easier for you. Consider this as "creating your own interpretation" of the piece.
Good luck and have fun with your music!