<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Darpan Wani</title>
    <description>The latest articles on Forem by Darpan Wani (@darpan_wani_00f6629054089).</description>
    <link>https://forem.com/darpan_wani_00f6629054089</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2047822%2F2a847837-6210-4929-a9ea-36bcf2ac2489.png</url>
      <title>Forem: Darpan Wani</title>
      <link>https://forem.com/darpan_wani_00f6629054089</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/darpan_wani_00f6629054089"/>
    <language>en</language>
    <item>
      <title>How to fetch full URL and store in hidden field on pardot form</title>
      <dc:creator>Darpan Wani</dc:creator>
      <pubDate>Mon, 09 Sep 2024 14:20:11 +0000</pubDate>
      <link>https://forem.com/darpan_wani_00f6629054089/how-to-fetch-full-url-and-store-in-hidden-field-on-pardot-form-2i0h</link>
      <guid>https://forem.com/darpan_wani_00f6629054089/how-to-fetch-full-url-and-store-in-hidden-field-on-pardot-form-2i0h</guid>
      <description>&lt;p&gt;This is my code added to the Pardot form below section,&lt;/p&gt;

&lt;p&gt;// Parse the URL&lt;/p&gt;

&lt;p&gt;function getParameterByName(name) {&lt;br&gt;
    name = name.replace(/[[]/, "\[").replace(/[]]/, "\]");&lt;br&gt;
    var regex = new RegExp("[\?&amp;amp;]" + name + "=([^&amp;amp;#]*)"),&lt;br&gt;
    results = regex.exec(location.search);&lt;br&gt;
    return results === null ? "" : decodeURIComponent(results[1].replace(/+/g, " "));&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;// Give the URL parameters variable names&lt;/p&gt;

&lt;p&gt;var source = getParameterByName('utm_source');&lt;br&gt;
var medium = getParameterByName('utm_medium');&lt;br&gt;
var campaign = getParameterByName('utm_campaign');&lt;br&gt;
var content = getParameterByName('utm_content');&lt;br&gt;
var term = getParameterByName('utm_term');&lt;br&gt;
var campaignID = getParameterByName('URL_Campaign_Id');&lt;/p&gt;

&lt;p&gt;// GET the URL of the Parent Page&lt;/p&gt;

&lt;p&gt;var url = window.location.href;&lt;/p&gt;

&lt;p&gt;// Put the variable names into the hidden fields in the form. selector should be "p.YOURFIELDNAME input"&lt;/p&gt;

&lt;p&gt;document.querySelector("p.utm_source input").value = source;&lt;br&gt;
document.querySelector("p.utm_medium input").value = medium;&lt;br&gt;
document.querySelector("p.utm_campaign input").value = campaign;&lt;br&gt;
document.querySelector("p.utm_content input").value = content;&lt;br&gt;
document.querySelector("p.utm_term input").value = term;&lt;br&gt;
document.querySelector("p.URL_Campaign_Id input").value = campaignID;&lt;br&gt;
document.querySelector('input[name="Source_URL"]').value = url;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn4ytblgmqiazcjtz1195.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn4ytblgmqiazcjtz1195.png" alt="Image description" width="800" height="410"&gt;&lt;/a&gt;&lt;br&gt;
I want to fetch the URL of the form and store it in the hidden field(Source_URL) when someone submits the Pardot form the whole code works fine but just the part of fetching the URL and storing to "Source_URL" hidden field is not working.&lt;/p&gt;

&lt;p&gt;Does anyone have a solution what change do I have to make here?&lt;/p&gt;

&lt;p&gt;Adding image of code also to clearly understand the code&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>programming</category>
      <category>pardot</category>
    </item>
  </channel>
</rss>
