The Ophiuchus clouds, in particular L~1688, are an excellent region to study the embedded phases of star formation, due to the relatively large number of protostars. However, the standard method of finding and characterizing embedded young stellar objects (YSOs) through just their infrared spectral slope does not yield a reliable sample. This may affect the age determinations, often derived from the statistics on the total number of embedded YSOs and pre-main sequence stars within a cloud.Our aim is to characterize the structure of protostellar envelopes on an individual basis and to correctly identify the embedded YSO population of L1688. Spectral maps of the HCO+ J=4--3 and C18O J=3--2 lines using the HARP-B array on the James Clerk Maxwell Telescope and SCUBA 850 micron dust maps are obtained of all sources in the L1688 region with infrared spectral slopes consistent with, or close to, that of embedded YSOs. Selected 350 micron maps obtained with the Caltech Submillimeter Observatory are presented as well. The properties, extent and variation of dense gas, column density and dust on scalesup to 1 are probed at 15 resolution. Using the spatial variation of the gas and dust, together with the intensity of the HCO+ J=4--3 line, we are able to accurately identify the truly embedded YSOs and determine their properties. RESULTS The protostellar envelopes range from 0.05 to 0.5 Msun in mass. The concentration of HCO+ emission (~0.5 to 0.9) is generally higher than that of the dust concentration. Combined with absolute intensities, HCO+ proves to be a better tracer of protostellar envelopes than dust, which can contain disk and cloud contributions. Our total sample of 45 sources, including all previously classified Class I sources, several flat-spectrum sources and some known disks, was re-classified using the ....