This paper describes the preparation and testing of a sol gel specific for the non-steroidal anti-inflammatory drug ibuprofen. Ibuprofen was selected as a model compound due to the fact that it contains a number of structural and functional analogues, in this case ketoprofen and naproxen. In order to study the specific criteria affecting selectivity in sol gels, three sol gels were prepared for ibuprofen utilising two and three functional silane systems. The relative rebinding of each of the three compounds to the sol gels was assessed by % recovery in solid phase extraction. The results of the experiments indicate that along with the functionality imparted to the sol gel by the development of template-monomer complexes a major determinant of selectivity is shape selective memory. The utilisation of a three monomer system affords the cavity recognition based on the formation of pi-pi stacking interactions, hydrogen bonding, van der Waals forces, electrostatic interactions and shape complementarity and minimises cross reactivity. In addition real sample analysis has been performed on urine samples containing ibuprofen and metabolites showing specific preconcentration. (C) 2009 Elsevier B.V. All rights reserved.