Preserving Referrer through a javascript redirect

On the landing page that might use a javscript redirect, place this bit of code:

<script type="text/javascript">var monitus=monitus||{}; monitus.id=[[monitus store ID]];</script>
<script type="text/javascript" src="http://ldn..monitus.net/js/monitus.js"></script>
<script type="text/javascript">try{jMUI.yahoo.save_referrer_for_redirect();}catch(e){}</script>
[[...actual redirect script...]]
<script type="text/javascript">try{jMUI.yahoo.clear_referrer_for_redirect();}catch(e){}</script>

Then, on the redirected page, we need to grab the referrer back before we use it. In this example, we use the out-of-the-box GA code on the redirected page:

<script type="text/javascript" src="http://ldn..monitus.net/jmui.js"></script>
<script type="text/javascript">>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-1']);
var overridenRef = jMUI.utilities.cookie_value("_mrrf", null);
if(overridenRef) _gaq.push(['_setReferrerOverride', overridenRef]);
MUI.yahoo.clear_referrer_for_redirect();
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('http:' == document.location.protocol ? 'http://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>

Note: If the code is placed on a secure page (https), then the jMUI URL changes from "http://ldn..monitus.net/jmui.js" to "http://d35q1w5azactrh.cloudfront.net/jmui.js"