How to add current user recordId into url

This is used to have a profile page opening from a page like /profile

<script>
    document.addEventListener("DOMContentLoaded", function() {    
        if(window.logged_in_user && window.logged_in_user['airtable_record_id']) {
            $('nav a').each(function(){
                if($(this).attr('href').endsWith('/profile')) {
                    $(this).attr('href', $(this).attr('href') + '?recordId=' + window.logged_in_user['airtable_record_id']);
                }
            });
        }
    });
</script>

Hi, thanks for this! I have entered this into my header code but there is still no record-id showing in the URL.