How to retrieve UTMs in forms with Pardot IFRAME

As we discussed in our previous article on the “Google Analytics Connector for Pardot”, it is not always easy to retrieve the UTMs so that this information appears to you in the leads once you activate the Google Analytics Connector. In this article we are going to see how to retrieve the UTM in forms with Pardot Iframe.


How to retrieve utms in forms with pardot iframe


The possible cases are:


  1. If you can touch the server code, add the variables there through your back programming code: PHP, JAVA, .NET, etc.
  2. In case you can’t touch it, add those IFRAMES with a javascript code.
  3. If you cannot do either one or the other, you have no choice but to add it in the Pardot FORM. There you can add a javascript to retrieve that information. 


Use server code


For this, the normal thing is that you count on your IT department, theirs is to save the information of the UTM in session and then print it in the iframe, if the iframe has the structure:



<iframe src=”https://dominio.ejemplo/l/10/2011-00-02/12345″ width=”100%” height=”500″ type=”text/html frameborder=”0″ allowTransparency=”true” style=”border: 0″></iframe> 


We should include the utm by code, if it were php it would be something like this:


<iframe src=”https://dominio.ejemplo/l/10/2011-00-02/12345?utm_source=<?=$utmSource?>&utm_medium= <?=$utmMedium?> &utm_campaign=<?=utmCampaign?>&utm_term= <?=$utmTerm?>&utm_content= <?=$utmContent?> width=”100%” height=”500″ type=”text/html frameborder=”0″ allowTransparency=”true” style=”border: 0″></iframe> 


Adding javascript code in the “parent” page 


If we want to include the javascript code instead of server code because we have a CMS that does allow us this code from its manager or for any other reason, we would have to include something like this for each form:



<iframe src=” https://dominio.ejemplo/l/10/2011-00-02/12345 L” width=”100%” height=”500″ type=”text/html frameborder=”0″ allowTransparency=”true” style=”border: 0″></iframe> 



<script type=”text/javascript“> 

var form = ‘ https://dominio.ejemplo/l/10/2011-00-02/12345‘; 

var params =; 

var thisScript = document.scripts[document.scripts.length – 1]; 

var iframe = document.createElement(‘iframe‘); 

 iframe.setAttribute(‘src‘, form + params); 

iframe.setAttribute(‘width‘, ‘100%’); 

iframe.setAttribute(‘height‘, 500); 

iframe.setAttribute(‘type‘, ‘text/html‘); 

iframe.setAttribute(‘frameborder‘, 0); 

iframe.setAttribute(‘allowTransparency‘, ‘true’); = ‘0’; 

 thisScript.parentElement.replaceChild(iframe, thisScript);