This is an analytical study of the effect of level-shift and temporary-change components, when present but neglected, on the trace test for cointegration. The contribution is threefold. First, we discuss in a multivariate framework, and jointly, effects that in the previous literature have been discussed in a univariate setting and in isolation. Second, we consider a rather general specification of shifts and outliers with random size, number, and timing and with flexible dynamics. It nests the classical cases of additive shifts, innovational outliers, and additive outliers. Third, as an instrument for this analysis we develop an asymptotic theory for product moment matrices of linear processes with stochastic level-shift components, generalizing results of Leipus and Viano (2003, Statistics and Probability Letters 61, 177–190).