An occupancy detector detects the presence of a train, engine or cars at a
particular location, to operate signals, crossing gates, etc.
The coil-type DCC occupancy detectors work by sensing electrical current flow
in the stretch of track they are connected to. In order to detect cars, you
have to install a resistor across one (or more) of the car's wheelsets, so
some small current flows.
The rails (actually, only one) must be gapped to isolate the occupancy
detector from the rest of the layout, otherwise, it will detect
trains/engines/cars everywhere and not just within the limits that you want.
The most common installation would be for a signal system (or even CTC) where
the mainline would be divided into "blocks" with a signal governing entry into
the block. The detector feedback would be used by the signal logic to
determine which signals should be red, yellow, or green.