Skip to content

Instantly share code, notes, and snippets.

View PardotGists's full-sized avatar

Pardot Gists PardotGists

View GitHub Profile
@PardotGists
PardotGists / 2126659-redirecting-to-thank-you-pages-based-on-form-field-values2.js
Last active September 25, 2015 21:38
Redirecting to Thank You Pages Based on Form Field Values snippet
case '<strong>Live Demo</strong>':
document.location='http://www.yoursite.com/thank-you-live-demo/';
break;
@PardotGists
PardotGists / 2126659-redirecting-to-thank-you-pages-based-on-form-field-values1.js
Last active November 23, 2015 15:27
Redirecting to Thank You Pages Based on Form Field Values main example
<script type="text/javascript">
switch('%%Free_Trial_Live_Demo_{js}%%') {
case 'Free Trial':
document.location='http://www.yoursite.com/thank-you-free-trial/';
break;
case 'Live Demo':
document.location='http://www.yoursite.com/thank-you-live-demo/';
break;
}
</script>
@PardotGists
PardotGists / 2126658-redirecting-your-form-automatically-after-displaying-thank-you-content2.js
Last active July 25, 2016 19:33
Redirecting Your Form Automatically After Displaying Thank You Content Iframe version
<script type="text/javascript">// <![CDATA[
var howLongToWait = 5; //number of seconds to wait
var urlOfDownloadContent = 'http://www.example.com/whitepaper.pdf';
function triggerDownload() {
window.location = urlOfDownloadContent;
}
setTimeout('triggerDownload()', howLongToWait * 1000);
// ]]>
</script><script type="text/javascript">
var howLongToWait = 5; //number of seconds to wait
@PardotGists
PardotGists / 2126658-redirecting-your-form-automatically-after-displaying-thank-you-content1.js
Last active July 25, 2016 19:32
Redirecting Your Form Automatically After Displaying Thank You Content Example 1
<script type="text/javascript">// <![CDATA[
var howLongToWait = 2; //number of seconds to wait
var urlOfDownloadContent = 'http://www.example.com/whitepaper.pdf';
function triggerDownload() {
window.location = urlOfDownloadContent;
}
setTimeout('triggerDownload()', howLongToWait * 1000);
// ]]>
</script><script type="text/javascript">
var howLongToWait = 5; //number of seconds to wait
@PardotGists
PardotGists / 2126656-preventing-competitors-from-accessing-content-on-form-submission1.js
Last active November 23, 2015 18:34
Preventing Competitors from Accessing Content on Form Submission thank you code
<script type="text/javascript">
var email = "%%email{js}%%"; //set the field name to a local javascript variable
if (email.indexOf("@competitor1.com")!=-1){ //if the string has the competitor name
top.location="http://loc1"; //redirect to a location
} else if (email.indexOf("@competitor2.com")!=-1){
top.location="http://loc2";
} else { //go to the real location
top.location="http://nonCompetitorLocation";
}
</script>
@PardotGists
PardotGists / 2126654-populate-hidden-field-on-form-with-name-of-webpage-.js
Created September 25, 2015 20:40
Populate Hidden Field on Form with Name of Webpage
<script type="text/javascript">
var fieldId = "Custom_Field_ID";
var formUrl = "http://cname.company.com/12345/ABCDE";
var title = encodeURI(document.title);
document.write('<iframe width="100%" height="300" frameborder="0" style="border: 0;" src="' + formUrl);
document.write('?' + fieldId + '=' + title);
document.write('"></iframe>');
</script>
@PardotGists
PardotGists / 2126647-passing-url-parameters-from-browser-to-iframe.js
Created September 25, 2015 19:52
Passing URL Parameters from Browser to iframe
<noscript>
<iframe src="PARDOT_FORM_URL" width="100%" height="500" type="text/html" frameborder="0" allowTransparency="true" style="border: 0"></iframe>
</noscript>
<script type="text/javascript">
var form = 'PARDOT_FORM_URL';
var params = window.location.search;
var thisScript = document.scripts[document.scripts.length - 1];
var iframe = document.createElement('iframe');
@PardotGists
PardotGists / 2125987-using-form-field-based-completion-actions2.js
Last active August 16, 2016 17:35
Using Form Field-Based Completion Actions additional required field example
<script type="text/javascript">
var email = encodeURIComponent('%%email{js}%%')
switch('%%your_field_id{js}%%')
{
case 'VALUE_1': document.write('<iframe src="FORM_HANDLER_1_URL?email=' + email + '&your_required_field1=%%your_required_field1%%&your_required_field2=%%your_required_field2%%" height="1px" width="1px" />');
break;
case 'VALUE_2': document.write('<iframe src="FORM_HANDLER_2_URL?email=' + email + '&your_required_field1=%%your_required_field1%%&your_required_field2=%%your_required_field2%%" height="1px" width="1px" />');
break;
}
</script>
@PardotGists
PardotGists / 2125987-using-form-field-based-completion-actions3.js
Last active January 16, 2017 20:02
Using Form Field-Based Completion Actions Additional Cases
case 'VALUE_3': document.write('<iframe src="FORM_HANDLER_3_URL?email=' + email + '&your_required_field1=%%your_required_field1%%&your_required_field2=%%your_required_field2%%" height="1px" width="1px" />');
break;
@PardotGists
PardotGists / 2125987-using-form-field-based-completion-actions1.js
Last active February 15, 2022 15:39
Using Form Field-Based Completion Actions Thank You Code Script
<script type="text/javascript">
var email = encodeURIComponent('%%email{js}%%')
switch('%%your_field_id{js}%%')
{
case 'VALUE_1': document.write('<iframe src="FORM_HANDLER_1_URL?email=' + email + '" height="1px" width="1px" />');
break;
case 'VALUE_2': document.write('<iframe src="FORM_HANDLER_2_URL?email=' + email + '" height="1px" width="1px" />');
break;
}
</script>