Referrer URL Tracking

I'm trying to get the inital/referrer url of the site where the user entered and store it in a hidden value in the pop-up(which is same on all pages) from and take it as a submission when form is submitted.

tried this but wasn't working
<script>
  $(document).ready(function () {
    // Get the Referrer URL
    var referrerURL = document.referrer;

    // Set the Referrer URL as the value of the hidden input field
    $("#name=Last_Conversion_Page_URL__c").val(referrerURL);
  });
</script>

<input type="hidden" class="last-conversion-fl last_con_url w-input" id="name=Last_Conversion_Page_URL__c" name="Last_Conversion_Page_URL__c" data-name="Last_Conversion_Page_URL__c" value="https://www.wesite.com/pop-up ">


how can I achieve this?
Is this possible to achieve something like this?
Was this page helpful?