The optimization of a GC-MS analytical procedure which includes derivatization, Quick Easy Cheap Effective Rugged and Safe (QuEChERS) and programmed temperature vaporization (PTV) using design of experiments is performed to determine 2,6dichlorobenzonitrile (dichlobenil) and 2,6dichlorobenzamide (BAM) in onions, using 3,5dichlorobenzonitrile and 2,4dichlorobenzamide as internal standards. The use of a central composite design and two D-optimal designs, together with the desirability function, makes it possible to significantly reduce the economic, time and environmental cost of the study. The usefulness of PARAFAC2 for solving problems as the interference of unexpected derivatization artifacts unavoidably linked to some derivatization agents, or the presence of coeluents from the complex matrix, which share m/z ratios with the target compounds, is shown. The limits of decision (CC) of the optimized procedure, 5.00 g kg -1 for dichlobenil and 1.55 g kg -1 for BAM (=0.05), are bellow the maximum residue limit (MRL) established by the EU for dichlobenil (20 g kg -1 ) in this commodity.