Jimmy Floyd Hasselbaink and Eidur Gudjohnsen both struck two goals in the 5-1 rout of the Hammers.
Ranieri said: "The big group of clubs were getting away, so it was very important to win today. Now we are near the group."
West Ham keeper David James pulled off some great saves to prevent the Blues running up a cricket score - but he could not prevent Hasselbaink rifling home in the 45th and 60th minutes, either side of a superb finish by his strike partner Gudjohnsen.
Just when the 3,000 West Ham fans thought their afternoon could not get any worse, Paolo di Canio stamped on Jody Morris and was shown the red card by referee Andy D'Urso.
In a frantic finale, with three goals in as many minutes, Gudjohnsen first produced a cool finish for his second in the 86th minute.
Just 60 seconds later, Jermain Defoe hit a fine consolation goal - and in the 89th minute Mikael Forssell sidefooted home his side's fifth from 14 yards.
Ranieri added: "Without Jimmy, we scored four (against Norwich) - so he was afraid because he thought he might not play. But I would never have left him out.
"It was a very good match because both teams played to win. In the first half there was a lot of touch-and-move - but we wanted to win and scored at the right moment. In the second half it was even better for us.
"Maybe we now have the psychological advantage for the FA Cup game also against West Ham, on Saturday - but I prefer the advantage on the pitch.
Every game has its own story."