<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How can I collect current page URL in form? in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239977#M18873</link>
    <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/shadministrator"&gt;@Shadministrator&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;The current page (or location) of the browser is stored in Window.location (see below). You could populate a hidden form field with this value by targeting the input using jQuery and setting the value to window.location. The form embed document below has some examples of this.&lt;/P&gt;
&lt;ASIDE class="onebox whitelistedgeneric"&gt;
  &lt;HEADER class="source"&gt;
      &lt;IMG src="https://cdn.mdn.mozilla.net/static/img/favicon32.7f3da72dcea1.png" class="site-icon" width="32" height="32" /&gt;
      &lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/Window/location" target="_blank" rel="nofollow noopener"&gt;Mozilla Developer Network&lt;/A&gt;
  &lt;/HEADER&gt;
  &lt;ARTICLE class="onebox-body"&gt;
    &lt;IMG src="https://cdn.mdn.mozilla.net/static/img/opengraph-logo.72382e605ce3.png" class="thumbnail onebox-avatar" width="500" height="500" /&gt;

&lt;H3&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/Window/location" target="_blank" rel="nofollow noopener"&gt;Window.location&lt;/A&gt;&lt;/H3&gt;

&lt;P&gt;The Window.location read-only property returns a Location object with information about the current location of the document.&lt;/P&gt;


  &lt;/ARTICLE&gt;
  &lt;DIV class="onebox-metadata"&gt;
    
    
  &lt;/DIV&gt;
  &lt;DIV style="clear: both"&gt;&lt;/DIV&gt;
&lt;/ASIDE&gt;

&lt;ASIDE class="onebox whitelistedgeneric"&gt;
  &lt;HEADER class="source"&gt;
      &lt;IMG src="https://developers.hubspot.com/hs-fs/hub/428357/file-2168997910-ico/favicon.ico?t=1511211924848" class="site-icon" width="16" height="16" /&gt;
      &lt;A href="https://developers.hubspot.com/docs/methods/forms/advanced_form_options" target="_blank" rel="nofollow noopener"&gt;developers.hubspot.com&lt;/A&gt;
  &lt;/HEADER&gt;
  &lt;ARTICLE class="onebox-body"&gt;
    

&lt;H3&gt;&lt;A href="https://developers.hubspot.com/docs/methods/forms/advanced_form_options" target="_blank" rel="nofollow noopener"&gt;How to customize the form embed code&lt;/A&gt;&lt;/H3&gt;

&lt;P&gt;This is a list of options that you can use if you just need to tweak a default hubspot form. If you need complete control over the styles and actions of your form, you will still want to use the Forms API.&lt;/P&gt;


  &lt;/ARTICLE&gt;
  &lt;DIV class="onebox-metadata"&gt;
    
    
  &lt;/DIV&gt;
  &lt;DIV style="clear: both"&gt;&lt;/DIV&gt;
&lt;/ASIDE&gt;</description>
    <pubDate>Tue, 17 Oct 2017 15:27:31 GMT</pubDate>
    <dc:creator>Derek_Gervais</dc:creator>
    <dc:date>2017-10-17T15:27:31Z</dc:date>
    <item>
      <title>How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239976#M18872</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Does anyone know if there’s a way to put a hidden text field in a Hubspot form and have it collect the current page url when the user submits the form? (through javascript or otherwise?)&lt;/P&gt;
&lt;P&gt;I feel like this is pretty basic but I’m not sure where to start. Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Oct 2017 20:58:12 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239976#M18872</guid>
      <dc:creator>Shadministrator</dc:creator>
      <dc:date>2017-10-16T20:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239977#M18873</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/shadministrator"&gt;@Shadministrator&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;The current page (or location) of the browser is stored in Window.location (see below). You could populate a hidden form field with this value by targeting the input using jQuery and setting the value to window.location. The form embed document below has some examples of this.&lt;/P&gt;
&lt;ASIDE class="onebox whitelistedgeneric"&gt;
  &lt;HEADER class="source"&gt;
      &lt;IMG src="https://cdn.mdn.mozilla.net/static/img/favicon32.7f3da72dcea1.png" class="site-icon" width="32" height="32" /&gt;
      &lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/Window/location" target="_blank" rel="nofollow noopener"&gt;Mozilla Developer Network&lt;/A&gt;
  &lt;/HEADER&gt;
  &lt;ARTICLE class="onebox-body"&gt;
    &lt;IMG src="https://cdn.mdn.mozilla.net/static/img/opengraph-logo.72382e605ce3.png" class="thumbnail onebox-avatar" width="500" height="500" /&gt;

&lt;H3&gt;&lt;A href="https://developer.mozilla.org/en-US/docs/Web/API/Window/location" target="_blank" rel="nofollow noopener"&gt;Window.location&lt;/A&gt;&lt;/H3&gt;

&lt;P&gt;The Window.location read-only property returns a Location object with information about the current location of the document.&lt;/P&gt;


  &lt;/ARTICLE&gt;
  &lt;DIV class="onebox-metadata"&gt;
    
    
  &lt;/DIV&gt;
  &lt;DIV style="clear: both"&gt;&lt;/DIV&gt;
&lt;/ASIDE&gt;

&lt;ASIDE class="onebox whitelistedgeneric"&gt;
  &lt;HEADER class="source"&gt;
      &lt;IMG src="https://developers.hubspot.com/hs-fs/hub/428357/file-2168997910-ico/favicon.ico?t=1511211924848" class="site-icon" width="16" height="16" /&gt;
      &lt;A href="https://developers.hubspot.com/docs/methods/forms/advanced_form_options" target="_blank" rel="nofollow noopener"&gt;developers.hubspot.com&lt;/A&gt;
  &lt;/HEADER&gt;
  &lt;ARTICLE class="onebox-body"&gt;
    

&lt;H3&gt;&lt;A href="https://developers.hubspot.com/docs/methods/forms/advanced_form_options" target="_blank" rel="nofollow noopener"&gt;How to customize the form embed code&lt;/A&gt;&lt;/H3&gt;

&lt;P&gt;This is a list of options that you can use if you just need to tweak a default hubspot form. If you need complete control over the styles and actions of your form, you will still want to use the Forms API.&lt;/P&gt;


  &lt;/ARTICLE&gt;
  &lt;DIV class="onebox-metadata"&gt;
    
    
  &lt;/DIV&gt;
  &lt;DIV style="clear: both"&gt;&lt;/DIV&gt;
&lt;/ASIDE&gt;</description>
      <pubDate>Tue, 17 Oct 2017 15:27:31 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239977#M18873</guid>
      <dc:creator>Derek_Gervais</dc:creator>
      <dc:date>2017-10-17T15:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239978#M18874</link>
      <description>&lt;P&gt;Ok, thanks for that Derek.&lt;/P&gt;
&lt;P&gt;So I did see this in the documentation - &lt;A href="https://developers.hubspot.com/docs/methods/forms/advanced_form_options" rel="nofollow noopener"&gt;https://developers.hubspot.com/docs/methods/forms/advanced_form_options&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I’m thinking I could just do:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;$('input[name="website"]').val(Window.location.href).change();
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The question is where do I put this code? I tried putting it in the embed code but it didn’t work. I feel like I’m missing something (or a few things). Any other advice on this greatly appreciated. Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2017 15:47:30 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239978#M18874</guid>
      <dc:creator>Shadministrator</dc:creator>
      <dc:date>2017-10-17T15:47:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239979#M18875</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/shadministrator"&gt;@Shadministrator&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;You could pass an &lt;CODE&gt;onFormReady&lt;/CODE&gt; callback function in the form embed code, and execute that within that callback. That should populate the hidden form field once the form has been rendered in the DOM. It’d look something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;hbspt.forms.create({
  portalId: '{your Hub ID}',
  formId: '{your form GUID}',
  onFormReady: function($form) {
    $('input[name="website"]').val(Window.location.href).change();
  }
});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Oct 2017 17:13:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239979#M18875</guid>
      <dc:creator>Derek_Gervais</dc:creator>
      <dc:date>2017-10-17T17:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239980#M18876</link>
      <description>&lt;P&gt;AWESOME!&lt;/P&gt;
&lt;P&gt;That works great, thanks Derek. Only thing I changed was the “Window.location.href” --&amp;gt; “window.location.href” (made the “W” lowercase).&lt;/P&gt;
&lt;P&gt;Hope this helps someone else.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2017 20:05:32 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239980#M18876</guid>
      <dc:creator>Shadministrator</dc:creator>
      <dc:date>2017-10-17T20:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239981#M18877</link>
      <description>&lt;P&gt;Thanks for the help guys. I cant seem to get my code to work with these steps above. Here is what I got:&lt;BR /&gt;
hbspt.forms.create({&lt;BR /&gt;
portalId: ‘XXXXXX’,&lt;BR /&gt;
formId: 'XXXX’&lt;BR /&gt;
onFormReady: function($form) {&lt;BR /&gt;
$(‘input[name=“sample_pn_url”]’).val(Window.location.href).change();&lt;BR /&gt;
}&lt;BR /&gt;
});&lt;/P&gt;
&lt;P&gt;sample_pn_url is the hidden field I am trying to write the URL to.&lt;/P&gt;
&lt;P&gt;Any help would be great!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 21:51:24 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239981#M18877</guid>
      <dc:creator>AnandV</dc:creator>
      <dc:date>2017-10-24T21:51:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239982#M18878</link>
      <description>&lt;P&gt;Hi Venkie,&lt;/P&gt;
&lt;P&gt;Make sure the “w” in “Window.location.href” is lowercase (should be “window.location.href”).&lt;/P&gt;
&lt;P&gt;Also, make sure “sample_pn_url” is the field id not the field name.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 22:15:02 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239982#M18878</guid>
      <dc:creator>Shadministrator</dc:creator>
      <dc:date>2017-10-24T22:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239983#M18879</link>
      <description>&lt;P&gt;&lt;A class="mention" href="https://community.hubspot.com/u/shadministrator"&gt;@Shadministrator&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Thanks for the quick reply and fixes. I changed the W to w, and I am still getting no luck. I checked that the sample_pn_url is the id. Any other suggestions?&lt;/P&gt;
&lt;P&gt;hbspt.forms.create({&lt;BR /&gt;
portalId: ‘XXX’,&lt;BR /&gt;
formId: ‘XXXXXX’,&lt;BR /&gt;
onFormReady: function($form) {&lt;BR /&gt;
$(‘input[name=“sample_pn_url”]’).val(window.location.href).change();&lt;BR /&gt;
}&lt;BR /&gt;
});&lt;/P&gt;</description>
      <pubDate>Tue, 24 Oct 2017 22:33:46 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239983#M18879</guid>
      <dc:creator>AnandV</dc:creator>
      <dc:date>2017-10-24T22:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239984#M18880</link>
      <description>&lt;P&gt;Venkie, did you get this to work? Often it’s the input name that spoils the party. To clarify, it’s not the “id”, it’s the “name”. Good idea to view the form source code and see if the name matches with your script.&lt;/P&gt;
&lt;P&gt;Here’s an example of a working configuration:&lt;/P&gt;
&lt;P&gt;hbspt.forms.create({&lt;BR /&gt;
portalId: ‘xxxxxxxx’,&lt;BR /&gt;
formId: ‘3f986685-13c9-4689-bfb6-3cb109b3169c’,&lt;BR /&gt;
css: ’ ',&lt;BR /&gt;
onFormReady: function($form){$(‘input[name=“last_conversion_location”]’).val(window.location.href).change();}&lt;BR /&gt;
});&lt;/P&gt;
&lt;P&gt;Of course I created a new conversion property “last conversion location”, which generated the field “name” last_conversion_location then added the hidden field on the form.&lt;/P&gt;
&lt;P&gt;Let me know if you still need help.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2017 21:50:49 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239984#M18880</guid>
      <dc:creator>das_kreitz</dc:creator>
      <dc:date>2017-12-12T21:50:49Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239985#M18881</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;I am not reaching the goal &lt;IMG src="https://community.hubspot.com/legacyfs/online/emojis/twitter/frowning.png?v=5" title=":frowning:" class="emoji" alt=":frowning:" /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!--[if lte IE 8]&amp;gt;
  &amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"&amp;gt;&amp;lt;/script&amp;gt;
  &amp;lt;![endif]--&amp;gt;
  &amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script&amp;gt;
  hbspt.forms.create({
  portalId: 'XXXXXX',
  formId: '72b74198-7eda-41db-b85e-26720205d7a1',
  onFormReady: function($form){$(‘input[name=“website”]’).val().change(window.location.href);}
});
});
&amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is wrong with my code`?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 16:55:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239985#M18881</guid>
      <dc:creator>patrickhummel</dc:creator>
      <dc:date>2018-02-05T16:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239986#M18882</link>
      <description>&lt;P&gt;Hi Patrick,&lt;/P&gt;
&lt;P&gt;Make sure you have your own form id and the input name is correct (is the&lt;BR /&gt;
contact property you are trying to populate named “website” ?)&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 17:28:20 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239986#M18882</guid>
      <dc:creator>Shadministrator</dc:creator>
      <dc:date>2018-02-05T17:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239987#M18883</link>
      <description>&lt;P&gt;label and internal name is “website” and the form must be the right, otherwise the integration with HTML would not show this form or?&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.sorba.ch/kontakt-test" class="onebox" target="_blank" rel="nofollow noopener"&gt;http://www.sorba.ch/kontakt-test&lt;/A&gt;&lt;BR /&gt;
p: testSorba&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 18:04:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239987#M18883</guid>
      <dc:creator>patrickhummel</dc:creator>
      <dc:date>2018-02-05T18:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239988#M18884</link>
      <description>&lt;P&gt;Gonna go out on a limb here and suggest renaming your custom URL tracking field something besides “website”. HS already has a field for Website URL with an internal name of “website”. Try using the code I pasted above and rename your field to “last_conversion_location”.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 19:45:10 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239988#M18884</guid>
      <dc:creator>das_kreitz</dc:creator>
      <dc:date>2018-02-08T19:45:10Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239989#M18885</link>
      <description>&lt;P&gt;Thank you all for the attempts to help.&lt;BR /&gt;
HubSpot had a cache problem. My custom html box was not even loaded, so referring to the variable never would be possible. Deleting the whole module and setting up a new html box helped.&lt;/P&gt;
&lt;P&gt;Perhaps others need this information too &lt;IMG src="https://community.hubspot.com/legacyfs/online/emojis/twitter/wink.png?v=5" title=":wink:" class="emoji" alt=":wink:" /&gt; Later, the code from das_kreitz works perfectly.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 07:35:40 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239989#M18885</guid>
      <dc:creator>patrickhummel</dc:creator>
      <dc:date>2018-02-09T07:35:40Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239990#M18886</link>
      <description>&lt;P&gt;Thanks &lt;A class="mention" href="https://community.hubspot.com/u/derek_gervais"&gt;@Derek_Gervais&lt;/A&gt; - but window.location.href doesnt work within a cross domain iframe.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 10:15:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239990#M18886</guid>
      <dc:creator>modxb29</dc:creator>
      <dc:date>2018-04-16T10:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239991#M18887</link>
      <description>&lt;P&gt;Is there a reason why the form_page_url token would work on one domain and not a secondary domain?&lt;/P&gt;
&lt;P&gt;Using the code in this post helps collect the current url a form is submitted on in my primary domain. However, using the same exact setup, on a secondary domain it doesn't.&lt;/P&gt;
&lt;P&gt;I even created a second property to track separately from the the token on the primary domain and its not functioning either.&lt;/P&gt;
&lt;P&gt;My code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;&amp;lt;!-- [if lte IE 8]&amp;gt;
        &amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2-legacy.js"&amp;gt;&amp;lt;/script&amp;gt;
        &amp;lt;![endif]--&amp;gt;
        &amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/v2.js"&amp;gt;&amp;lt;/script&amp;gt;
        &amp;lt;script&amp;gt;
          hbspt.forms.create({
        	portalId: "XXX",
        	formId: "XXXXXX",
                css: '',
          onFormReady: function($form) {
         $('input[name="sample_pn_url"]').val(window.location.href).change();
          }
        });
        &amp;lt;/script&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Browser console does through this error:&lt;BR /&gt;
TypeError: $ is not a function&lt;BR /&gt;
at onFormReady (www.not_a_real_site.com./:313)&lt;BR /&gt;
at Object.runCustomerCallbackFunction (v2.js:9)&lt;BR /&gt;
at t.componentDidMount (v2.js:11)&lt;BR /&gt;
at r.notifyAll (v2.js:1)&lt;BR /&gt;
at r.close (v2.js:3)&lt;BR /&gt;
at r.closeAll (v2.js:4)&lt;BR /&gt;
at r.perform (v2.js:4)&lt;BR /&gt;
at f (v2.js:3)&lt;BR /&gt;
at r.perform (v2.js:4)&lt;BR /&gt;
at Object.batchedUpdates (v2.js:2)&lt;/P&gt;</description>
      <pubDate>Thu, 16 Aug 2018 14:24:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239991#M18887</guid>
      <dc:creator>marioSWP</dc:creator>
      <dc:date>2018-08-16T14:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239992#M18888</link>
      <description>&lt;P&gt;Hi &lt;A class="mention" href="https://community.hubspot.com/u/marioswp"&gt;@marioSWP&lt;/A&gt;,&lt;/P&gt;
&lt;P&gt;That error means that the jQuery function call (i.e. &lt;CODE&gt;$()&lt;/CODE&gt;) is undefined. I'd expect to see that error if you didn't have jQuery on your secondary domain.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 20:23:37 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/239992#M18888</guid>
      <dc:creator>Derek_Gervais</dc:creator>
      <dc:date>2018-08-21T20:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/258170#M23006</link>
      <description>&lt;P&gt;I am having a problem populating hidden fields when they are hidden, but not when they are normal.&amp;nbsp; I am using javascript to point at the form field like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;jQuery('input[id="last_known_conversion_page-customnumbersthatidontknowifishouldsharepublicly"]').val(window.location.href).change();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This javascript works to populate the field when the form field is added in HubSpot's form editor normally, but it does not work when I check the box to "Make this field hidden" in the HubSpot form editor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My clunky workaround is to add the field in HubSpot's form editor as a normal (not hidden) field, but then add&amp;nbsp;display:none that field's class to my CSS file:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;.hs_last_known_conversion_page {&lt;BR /&gt;display: none;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doing this does work, and the field populates and passes through.&amp;nbsp; But it's a hack that I will certainly forget by next year and then won't be able to figure why fields that aren't marked as hidden in HubSpot are being hidden.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a better way to be doing this in 2019?&amp;nbsp; I'm not sure if some of the information on this page hasn't changed in the past couple of years.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 23:59:16 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/258170#M23006</guid>
      <dc:creator>lukecoburn</dc:creator>
      <dc:date>2019-03-08T23:59:16Z</dc:date>
    </item>
    <item>
      <title>Re: How can I collect current page URL in form?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/442638#M43835</link>
      <description>&lt;P&gt;Hi, I'm traing to do the same thing but for me doesn't work,&lt;/P&gt;&lt;P&gt;any ideas please? I would like to know the window.location on ticket&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;script charset="utf-8" type="text/javascript" src="//js.hsforms.net/forms/shell.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;hbspt.forms.create({&lt;BR /&gt;region: "na1",&lt;BR /&gt;portalId: "19989707",&lt;BR /&gt;formId: "3563e074-7482-432b-a0f0-9d42ccdc541d"&lt;/P&gt;&lt;P&gt;onFormReady: function($form) {&lt;BR /&gt;$('input[name="actualurl"]').val(window.location.href).change();&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Jun 2021 06:43:54 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/How-can-I-collect-current-page-URL-in-form/m-p/442638#M43835</guid>
      <dc:creator>TFD</dc:creator>
      <dc:date>2021-06-01T06:43:54Z</dc:date>
    </item>
  </channel>
</rss>

