Beyond being enthralled to the Ring and under it’s power, Gollum was a hell of a lot more crafty and observant than he might look. He pretty much snuck around all over Middle Earth for decades observing all he could while going virtually unnoticed for most of it. And he was able to tail the Company of the Ring for weeks after they passed through Moria.