This is an example of the Gibbs sampling procedure for cointegrated models described in Koop, León-González and Strachan(2010), "Efficient Posterior Simulation for Cointegrated Models with Priors on the Cointegration Space", Econometric Reviews, vol. 29, no. 2, 224-242. This actually does just the flat prior, though adding the types of priors they describe isn't difficult.

The key idea in the paper is that you can avoid the difficult problem of sampling the cointegrating vector (which has a highly non-standard distribution) by temporarily shifting the normalization over to the loading matrix alpha. This makes the "B" matrix (rather than the original beta) conditionally Normal.

This samples the alpha and the augmenting lags on the differences in one Gibbs block given beta and the covariance matrix sigma, then sigma given the residuals from the model, then beta (or actually "B") given alpha. The alpha and beta need to be renormalized at the end.