How can I collect current page URL in form?

Thanks for the help guys. I cant seem to get my code to work with these steps above. Here is what I got:
hbspt.forms.create({
portalId: ‘XXXXXX’,
formId: 'XXXX’
onFormReady: function($form) {
$(‘input[name=“sample_pn_url”]’).val(Window.location.href).change();
}
});

sample_pn_url is the hidden field I am trying to write the URL to.

Any help would be great!