  Multi-wavelength astronomical studies brings a wealth of science within
reach. One way to achieve a cross-wavelength analysis is via `stacking', i.e.
combining precise positional information from an image at one wavelength with
data from one at another wavelength in order to extract source-flux
distributions and other derived quantities. For the first time we extend
stacking to include the effects of confusion. We develop our algorithm in a
fully Bayesian framework and apply it to the Square Kilometre Array Design
Study (SKADS) simulation in order to extract galaxy number counts. Previous
studies have shown that recovered source counts are highly biased high when
confusion is non-negligible. With this new method, source counts are returned
correctly. We also describe a novel estimator for quantifying the impact of
confusion on stacking analyses. This method is an essential step in exploiting
scientific return for upcoming deep radio surveys, e.g. MIGHTEE on MeerKAT.
