Snakes use their tongues for collecting chemicals from the air or ground. The tongue does not have receptors to taste or smell. Instead, these receptors are in the vomeronasal, or Jacobson’s Organ, which is in the roof of the mouth. Once inside the Jacobson’s Organ, different chemicals evoke different electrical signals which are relayed to the brain.
It was once thought that the tongue delivered chemicals directly to the Jacobson’s Organ, because both the organ and the pathways that lead to it are paired just like the tips of the tongue. But X-ray movies have revealed that the tongue does not move inside the closed mouth, it simply deposits the chemicals it has collected onto pads on the floor of the mouth as the mouth is closing.
It is most likely that these pads deliver the sampled molecules to the entrance of the Jacobson’s Organ when the floor of the mouth is elevated to come into contact with the roof following a tongue flick. The case for this is strengthened because geckos, skinks, and other lizards lack deeply-forked tongues but still deliver chemicals to their vomeronasal organs.
I have noted (as an owner of this sort of creature) that the tongue-flicking is just about the only indication I have of the creature’s interest level. For example, lazy and relaxed is like, “flick….flick…….stare………..flick…..stare……flick,” while excited/hungry/scared/whatever is more like “FLICKFLICKFLICKFLICKFLICK.”