We study the possible contribution of a stochastic gravitational wave background to the anisotropy of the cosmic microwave background (CMB) in cold and mixed dark matter models. We test this contribution against recent detections of CMB anisotropy at large and intermediate angular scales. Our likelihood analysis indicates that models with blue power spectra (n [?] 1.2) and a tensor-to-scalar quadrupole ratio of R = CT2/CS2 ~2 are most consistent with the anisotropy data considered here. We find that by including the possibility of such a background in the CMB data analysis, it can drastically alter the conclusion of the remaining cosmological parameters.