How to get a single depth value of an object within a material?

Huh, more obvious than I thought it would be and this setup seems to do exactly what I need.