This is a good approach, but for some reason the random number wasn't generated before the condition was checked, so no banner was shown.
To solve this - we kept the random js variable set by the extension and mapped it to a custom container. In the custom container, the code looks like this:
if (data.random > 5)
html = 'banner 1 html';
html = 'banner 2 html';
var div = document.createElement('div');
div.innerHTML = html;
var child = document.getElementById('bannerdiv');
var parent = child.parentNode;
Thanks for all your help Dan and Steve, and a shout-out to Stuart Roskelley who implemented this for us.