function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ShawnFShawnF 

Third-Party Form on a Force.com Site Visualforce Page

My current employer, Digital Realty Trust, runs a portion of the corporate website as a Force.com Site; anything at (http://datacenters.digitalrealtytrust.com/) is a Force.com Site.

 

We also use Marketo as our “lead capture” system and I am trying to use a form script provided by Marketo on a Visualforce page to allow the end user to ‘request more information’.

 

So, here is what I’ve done:

 

  1. I build a simple vf test page in Sandbox (code provided below)
  2. I follow the instructions provided by Marketo (in their knowledge article)
  3. I complete the form
  4. I click the submit button
  5. I get the thank you page as expected
  6. Therefore, to the end user, it appears as though everything has worked correctly

Problem is: Marketo doesn’t register the form submit. When I look for the test data in Marketo, there is no activity regarding the form submit.

 

Are there known issues with using a third party form where I am forced to use the normal HTML <form></form> script instead of using the <apex:form></apex:form> syntax prescribed by Apex?

 

Here is my very simple vf page for reference. NOTE: I had to remove all the picklist options from the form below because this board said I was over the 20,000 character limit.

 

 

<apex:page standardController="Spec_Sheet__c">
<head>
<!-- SYSTEM JAVASCRIPT - DO NOT EDIT -->
<script type="text/javascript">
function fieldValidate(field) {
  /* call Mkto.setError(field, message) and return false to mark a field value invalid */
  /* return 'skip' to bypass the built-in validations */
  return true;
}
function getRequiredFieldMessage(domElement, label) {
  return "This field is required";
}
function getTelephoneInvalidMessage(domElement, label) {
  return "Please enter a valid telephone number";
}
function getEmailInvalidMessage(domElement, label) {
  return "Please enter a valid email address";
}
</script>
</head>

<form class="lpeRegForm formNotEmpty" method="post" enctype="application/x-www-form-urlencoded" action="http://info.digitalrealtytrust.com/index.php/leadCapture/save" id="mktForm_1042" name="mktForm_1042"><ul class='mktLblCenter'><li  class='mktFormReq mktField' ><label>First Name:</label><span class='mktInput'><input class='mktFormText mktFormString mktFReq' name="FirstName" id="FirstName" type='text' value=""  maxlength='255' tabIndex='1' /><span class='mktFormMsg'></span></span></li>
<li  class='mktFormReq mktField' ><label>Last Name:</label><span class='mktInput'><input class='mktFormText mktFormString mktFReq' name="LastName" id="LastName" type='text' value=""  maxlength='255' tabIndex='2' /><span class='mktFormMsg'></span></span></li>
<li  class='mktFormReq mktField' ><label>Company:</label><span class='mktInput'><input class='mktFormText mktFormString mktFReq' name="Company" id="Company" type='text' value=""  maxlength='255' tabIndex='3' /><span class='mktFormMsg'></span></span></li>
<li  class='mktFormReq mktField' ><label>Email:</label><span class='mktInput'><input class='mktFormText mktFormEmail mktFReq' name="Email" id="Email" type='text' value=""  maxlength='255' tabIndex='4' /><span class='mktFormMsg'></span></span></li>
<li  class='mktFormReq mktField' ><label>Phone:</label><span class='mktInput'><input class='mktFormText mktFormString mktFReq' name="MainPhone" id="MainPhone" type='text' value=""  maxlength='255' tabIndex='5' /><span class='mktFormMsg'></span></span></li>
<li  class='mktFormReq mktField' ><label>Your Country:</label><span class='mktInput'><select class='mktFormSelect mktFReq' name="Country" id="Country" size='1'  tabIndex='6'><option value='' selected='selected'>Please choose...</option></select><span class='mktFormMsg'></span></span></li>

<li  class='mktFormReq mktField' ><label>Company HQ Country:</label><span class='mktInput'><select class='mktFormSelect mktFReq' name="Company_HQ_Country__c" id="Company_HQ_Country__c" size='1'  tabIndex='7'><option value='' selected='selected'>Please choose...</option></select><span class='mktFormMsg'></span></span></li>

<li  class='mktField' ><label>Company HQ State:</label><span class='mktInput'><select class='mktFormSelect' name="Company_HQ_State__c" id="Company_HQ_State__c" size='1'  tabIndex='8'><option value='Please choose...' selected='selected'>Please choose...</option></select><span class='mktFormMsg'></span></span></li>

<li  class='mktFormReq mktField' ><label>Organization Level:</label><span class='mktInput'><select class='mktFormSelect mktFReq' name="Organization_Level__c" id="Organization_Level__c" size='1'  tabIndex='9'><option value='Please choose...' selected='selected'>Please choose...</option></select><span class='mktFormMsg'></span></span></li>
<li  class='mktFormReq mktField' ><label>Decision Timeframe:</label><span class='mktInput'><select class='mktFormSelect mktFReq' name="Timeframe__c" id="Timeframe__c" size='1'  tabIndex='10'><option value='Please choose...' selected='selected'>Please choose...</option></select><span class='mktFormMsg'></span></span></li>

<li  class='mktField' ><label>Datacenter Size Need:</label><span class='mktInput'><select class='mktFormSelect' name="Size_Need__c" id="Size_Need__c" size='1'  tabIndex='11'><option value='Please choose...' selected='selected'>Please choose...</option></select><span class='mktFormMsg'></span></span></li>
<li  class='mktField' ><label>Racks Required:</label><span class='mktInput'><select class='mktFormSelect' name="Racks_Required__c" id="Racks_Required__c" size='1'  tabIndex='12'><option value='Please choose...' selected='selected'>Please choose...</option></select><span class='mktFormMsg'></span></span></li>

<li  class='mktField' ><label>Website Form Comments:</label><span class='mktInput'><textarea class='mktFormTextarea mktFormTextarea' name="Website_Form_Comments_del__c" id="Website_Form_Comments_del__c" cols='20' rows='2' tabIndex='13'></textarea><span class='mktFormMsg'></span></span></li>
<li  class='mktField' style="display: none;"><label>Property ID:</label><span class='mktInput'><input class='mktFormHidden' name="Property_ID__c" id="Property_ID__c" type='hidden' value="" /><span class='mktFormMsg'></span></span></li>
<li  class='mktField' style="display: none;"><label>Suite:</label><span class='mktInput'><input class='mktFormHidden' name="Suite__c" id="Suite__c" type='hidden' value="" /><span class='mktFormMsg'></span></span></li>
<li id='mktFrmButtons'><label>&nbsp;</label><input id='mktFrmSubmit' type='submit' style="width: auto; overflow: visible; padding-left: .25em; padding-right: .25em;" value='Submit' name='submitButton' onclick='formSubmit(document.getElementById("mktForm_1042")); return false;' />&nbsp;<input style='display: none;' id='mktFrmReset' type='reset' 
              value='Clear' name='resetButton' onclick='formReset(document.getElementById("mktForm_1042")); return false;' /></li>     
  </ul>
  <span style="display:none;"><input type="text" name="_marketo_comments" value="" /></span>
  <input type="hidden" name="lpId" value="-1" />
  <input type="hidden" name="subId" value="80" />
  <input type="hidden" name="kw" value="" />

  <input type="hidden" name="cr" value="" />
  <input type="hidden" name="searchstr" value="" />
  <input type="hidden" name="lpurl" value="http://info.digitalrealtytrust.com/DatacenterLocator.html?cr={creative}&kw={keyword}" />
  <input type="hidden" name="formid" value="1042" />
  <input type="hidden" name="returnURL" value="http://www.digitalrealtytrust.com/" />
  <input type="hidden" name="retURL" value="http://www.digitalrealtytrust.com/" />
  <input type="hidden" name="_mkt_disp" value="return" />
      <input type="hidden" name="_mkt_trk" value="" />
  </form>

<script type="text/javascript" src="http://info.digitalrealtytrust.com/js/mktFormSupport.js"></script>
<script type="text/javascript">
function formSubmit(elt) {
  return Mkto.formSubmit(elt);
}
function formReset(elt) {
  return Mkto.formReset(elt);
}
</script>

</apex:page>

 

 

danpeterdanpeter

I'm curious on how to do this as well, so I looked into it.  Unfortunately it looks like using the standard apex:form and then using an apex method to do a pagereference.setRedirect can't be done with a POST when the domain is outside of salesforce!

 

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_pages_pagereference.htm

 

"Sets the value of the PageReference object's

redirect

attribute. If set to true, a redirect is performed through a client side redirect. This type of redirect performs an HTTP GET request, and flushes the view state, which uses POST. If set to false, the redirect is a server-side forward that preserves the view state if and only if the target page uses the same controller and contains the proper subset of extensions used by the source page.

Note that if the URL of the PageReference object is set to a website outside of the salesforce.com domain, or to a page with a different controller or controller extension, the redirect always occurs, regardless of whether the redirect attribute is set to true or false."

 

I wonder if salesforce has gone out of their way to not allow your use case?  Is it possible to use HTTP get instead of post for marketo's lead capture form?  If so, you are in good shape. 

 

If not, looks like you will have to figure out another way.

 

You should be able to do it as an http callout with the httpRequest class: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_http_httprequest.htm .  Set the body, method, endpoint as appropriate and fire it off.  Think you would have to add marketo's URL in your setup->security->remote site settings.

 

Try a plugin like firefox tamper to view what is acually being posted to your marketo form as well.  Try both with a force.com site page, and some other plain old HTML page somewhere else so you can compare.

 

Good luck, please post what works!

 

-Dan

 

 

ShawnFShawnF

While your solutions are creative, I was never able to get it to work. I had many of the same thoughts.

 

However, I had logged a ticket with Marketo Support (of course) while I was trying to get it working myself. Marketo Support has given me the official response stating, "Marketo functionality is not intended to work within Visualforce pages; this is by design. Integration with Visualforce is not on the current roadmap."

 

I was referred to the Marketo community site to create the idea and hopefully get it in the product roadmap.

 

So, unfortunately, at the time of this post it appears that "using a Marketo form on a non-Marketo page" in the context of a visualforce page as part of a Force.com Site is not possible.