You need to sign in to do that
Don't have an account?
pcotro
Help with non-standard SalesForce for Google AdWords lead to web form
Hi I'm having problems implementing SFGA on a web to lead form. Due to the requirements of the site I am developing, I can't use the standard ACTION for the form; the data must be captured in a database, sent via email and then a function is used to send it to Salesforce.com. The function's code (programmed in PHP) is as follows:
function sendToHost($host,$method,$path,$data,$useragent=0) {
if (empty($method)) {
$method = 'GET';
}
$method = strtoupper($method);
$fp = fsockopen($host, 80);
if ($method == 'GET') {
$path .= '?' . $data;
}
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
if ($method == 'POST') {
fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
}
if ($useragent) {
fputs($fp, "User-Agent: MSIE\r\n");
}
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') {
fputs($fp, $data);
}
$buf = "";
while (!feof($fp)) {
$buf .= fgets($fp,128);
$buf .= ".";
}
fclose($fp);
return $buf;
}
And is invoked with:
$sfdata = "oid=XXXXXXXXXXXXXXX" .
"&salutation=" . urlencode($HTTP_POST_VARS['x_salut']) .
"&first_name=" . urlencode($HTTP_POST_VARS['x_fname']) .
... all the form fields go here ... );
$out = sendToHost("www.salesforce.com", "POST", "/servlet/servlet.WebToLead?encoding=UTF-8", $sfdata);
The problem that I'm having is that I don't know how to do to add the google adwords processing to this form. The leads are being generated correctly.
Can anyone help me?
Thanks in advance
Patricio
function sendToHost($host,$method,$path,$data,$useragent=0) {
if (empty($method)) {
$method = 'GET';
}
$method = strtoupper($method);
$fp = fsockopen($host, 80);
if ($method == 'GET') {
$path .= '?' . $data;
}
fputs($fp, "$method $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
if ($method == 'POST') {
fputs($fp,"Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($data) . "\r\n");
}
if ($useragent) {
fputs($fp, "User-Agent: MSIE\r\n");
}
fputs($fp, "Connection: close\r\n\r\n");
if ($method == 'POST') {
fputs($fp, $data);
}
$buf = "";
while (!feof($fp)) {
$buf .= fgets($fp,128);
$buf .= ".";
}
fclose($fp);
return $buf;
}
And is invoked with:
$sfdata = "oid=XXXXXXXXXXXXXXX" .
"&salutation=" . urlencode($HTTP_POST_VARS['x_salut']) .
"&first_name=" . urlencode($HTTP_POST_VARS['x_fname']) .
... all the form fields go here ... );
$out = sendToHost("www.salesforce.com", "POST", "/servlet/servlet.WebToLead?encoding=UTF-8", $sfdata);
The problem that I'm having is that I don't know how to do to add the google adwords processing to this form. The leads are being generated correctly.
Can anyone help me?
Thanks in advance
Patricio
Message Edited by pcotro on 11-08-2007 12:43 PM
https://sfma.salesforce.com/lead_tracking_setup/printable_instructions
** NOTE: make sur eyou use your oid as appropriate in your HTML
Thanks,
-Kraig
----INSTRUCTIONS---
Some webmasters use 3rd party lead capture forms, or have created custom lead capture forms that preprocess lead data before inserting it into Salesforce. If you have any existing lead capture forms on your website, please confirm your character encoding is UTF-8 and place an extra hidden "sfga" field into your form as shown here:
<META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8">
...
<FORM action="http://www.mycompany.com/customform.php">
...
<!-- Add the following hidden field to your existing lead capture forms -->
<INPUT type="hidden" name="sfga" value="00D6000000075XI" />
...
</FORM>
Even though the script still tries to rework our HTML forms, it's futile for it to do so, because the form data is sent back to the server using a function tied to an INPUT type="button" that makes use of an XmlHttpRequest - this is done so that the form WON'T post back to the server & cause a page refresh (the response from the server is instead displayed inside a DIV in a manner similiar to how a modal dialog in Windows would). Forms using sfga.js (custom or otherwise), are essentially broken from our perspective, because it always tries to rewrite the ACTION attribute of the form (setting the "retURL" parameter to the original value) as well as the value of the hidden "sfga" field, but the ACTION itself is ignored by our web code (the insert of the lead into SF actually happens via server-side PHP, which works wonderfully).
Obviously, SalesForce expects their script to be able to take control of the form in question, and won't support any other means of submitting the form except the user physically clicking a "submit" button. There's a post somewhere (I couldn't find it again) that refers to SalesForce not supporting triggering the form's submit() method via JavaScript, which is exactly what I need to be able to do. >=(
So here I am, stuck, not able to get AdWords information into SF using Apex API calls (where does it go??), and I can't use sfga.js for the reasons described above. Any inquiry I've made into this issue has come back with fragmented information (for example, the responses given in this post http://community.salesforce.com/sforce/board/message?board.id=PerlDevelopment&message.id=2766). The other type of response I've seen are the sort that explain how to use a custom form without w2l (in great detail, I might add) using Apex API, but 99%; of them don't mention anything about how to handle AdWords information (such this post: http://community.salesforce.com/sforce/board/message?board.id=PerlDevelopment&message.id=2063 - great info, but no Google).
This issue has been plaguing me for over three months now - I'm ready to recommend that my company dump SalesForce completely because of this - good money is being thrown away because of the awful SFGA "integration" into existing sites, and we can't get the information we need without tearing down our site, starting with its foundation which, obviously, is not a reasonable option.
Any help would be extremely appreciated!!
Message Edited by GGF-ErikD on 01-10-2008 05:01 PM
First of all, I'm really happy I'm not the only person having this issue. Just about to pull my hair out with the same issues that all of you are having. I've been going back and forth with support and our email vendor which supplies the form code for over a month now. Organics are captured, but for some weird reason Paid keywords are not.
Patricio, in looking at your code I don't believe you can post oid and other field parameters through a script. I believe you have to set up some sort of API call to post data to SFDC?
The SFGA snippet did not work for me. But, it wouldn't hurt for you to try adding the suggested solution of using sfga field in place of the oid parameter.