Referrer URL with jQuery or Javascript – Cache & Referrer URL Issue

I don’t have the answer build on cookie, but I think this isn’t sensitive data, you can try localStorage.

jQuery(document).ready(function($){
    var initreferrer = document.referrer;
    if(initreferrer.indexOf('yourdomain.com') === -1 ) { // Check if the referer is your site or not. If not( return -1 ) set the localStorage.
        localStorage.setItem("mysite_referrer", initreferrer);
    }
});

Then you can use a javascript function (instead of a filter like you did) to fill your hidden field with the referer saved in browser localStorage. We can get it by localStorage.getItem("mystite_referer").