• abstractj
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 5
    Replies

Hi everyone,

 

We are using "Salesforce for Google AdWords" to generate the lead source for users filling out a web-to-lead form on our website. The form submission and lead source tagging works fine for people using Firefox or IE, but it breaks in Google Chrome.

 

I created a test form at http://staging.rightscale.com/products/euge_test.php that clearly shows that the bug lies in https://lct.salesforce.com/sfga.js. __kSetupForm() within the sfga.js seems to cause the bug in Google Chrome:

 

function __kSetupForm(form, customForm) {
if( customForm ) {
var sfga = __kgetSfgaField(form);
sfga.value = __kpackInfo(form, customForm);
form.setAttribute('action', __kgetSFAction(form));

} else {
_kwtlForm = form;
if( form.onsubmit != undefined ) {
var expr = "_kwtlOnSubmit = " + form.onsubmit.toString().replace(/this\s*([\)\.])/, '_kwtlForm$1');
eval(expr);
}
form.onsubmit = __konSubmit;
}
}

 

I was unable to find a support contact on Google's or SalesForce's end. Anybody ran into the same bug using "Salesforce for Google AdWords"? Thoughts?

Message Edited by AndreTheus on 01-26-2009 02:44 PM
Message Edited by AndreTheus on 01-26-2009 02:47 PM

What's up with this message I have been getting for the last 18 hours?  The Google Adwords Setup will not conclude, and the message seems to blame Google and hint that if Google doesn't fix it Salesforce is going to pull the service.

================

We are Processing Your Request

Your request to link Salesforce with your existing AdWords account is being processed.
Depending on the time of day, this may take a few hours.


Salesforce features related to the Google AdWords program depend on the continuing availability of the Google AdWords API and program for Salesforce. We may be required to discontinue features related to the Google AdWords program if Google ceases to make the Google AdWords API or program reasonably available for Salesforce.
Hello,
 
As you all are probably aware, you can send an email alert (in a workflow rule) to a sales team role.  I was wondering if there was a possibility to be able to send to a contact role?
Ok,
 
I have seen many posts in regards to submitting a custom form to Salesforce and generating a Lead and the Lead Source Details for Google Adwords.
I have taken the time to write a script that will do the trick for you. Let me know if you have any issues with it. See below...
 
Salesforce Fields
------------------------
oid={OID NUMBER}
retURL={CAN BE ANYTHING, JUST HAS TO BE THERE}
lead_source={LEAD SOURCE NAME}
Campaign_ID={CAMPAIGN_ID}
first_name={FIRST NAME}
last_name={LAST NAME}
company={COMPANY NAME}
landing={LANDING PAGE}
referrer={REFERER PAGE}
 
Example:
------------
oid=****&retURL=http//www.mysite.com/thanks.php&lead_source=Web+Referral&Campaign_ID=****&first_name=First&last_name=Last&company=Company&landing=http://www.mysite.com/myform.php&referrer=http://www.mysite.com/myprevpage.php
 
 
 
 
HTML/Javascript Code:
------------------------------
 
Put there two fields in your form (hidden)
---
<input type="hidden" name="landing" id="landing">
<input type="hidden" name="referrer" id="referrer">
 
 
Put this Salesforce code at the bottom of your page directly above the </body> tag
---
<script type="text/javascript" src="https://lct.salesforce.com/sfga.js"></script>
<script type="text/javascript">__sfga();</script>
<script type="text/javascript">
    var parts    = __kvalueOf('__kts').toString().split(',');
    var landing  = parts[1];
    var referrer = parts[2];
    document.getElementById('landing').value  = landing;
    document.getElementById('referrer').value = referrer;
</script>
 
 
PHP Code w/ cURL
-------------------------
<?php
$salesforce_url = 'http://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
$salesforce_data  = 'oid=****&retURL=http//www.mysite.com/thanks.php&lead_source=Web+Referral&Campaign_ID=****';
$salesforce_data .= '&first_name=First&last_name=Last&company=Company';
$salesforce_data .= '&landing=http://www.mysite.com/myform.php&referrer=http://www.mysite.com/myprevpage.php';
 
$salesforce_lead_source_url = 'https://lct.salesforce.com/sfga';
 
if( salesforce_lead($salesforce_url , $salesforce_data) && salesforce_lead_source($salesforce_lead_source_url, $salesforce_data) )
{
    #redirect to thank you page
    header("Location: thanks.php");
    exit;
}
else
{
    print('Error');
    exit;
}
 
Function salesforce_lead($url, $data)
{
    #submit to salesforce as lead
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $auth_result = curl_exec($ch);
    if( curl_errno($ch) ) //error
    {   
        print( curl_error($ch) );
        return false; 
    }
    else // success
    { 
        curl_close($ch);
        return true;
    }
}
 
Function salesforce_lead_source($url, $data)
{
    $t = timeAndMilliseconds();
    $r = $_POST['referrer'];
    $l = $_POST['landing'];
    $oid = '****';
 
    $sfga  = 't='.$t.'&r='.$r.'&l='.$l.'&oid='.$oid.'&ts='.$t.'&rs='.$r.'&ls='.$l;
    $sfga .= '&url='.urlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
    $sfga .= '&customForm=true&method=post&retURL='.urlencode('http://'.$_SERVER['HTTP_HOST'].'/newsletter-sign-up-thank-you.htm');
 
    #append sfga to the data that was previously submitted to salesforce
    $data .= '&sfga='.$sfga;
 
    #submit to salesforce as lead source to attach to lead
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $auth_result = curl_exec($ch);
    if( curl_errno($ch) ) //error
    {   
        print( curl_error($ch) );
        return false; 
    }
    else // success
    { 
        curl_close($ch);
        return true;
    }
}
 
Function timeAndMilliseconds()
{
    list($usec, $sec) = explode(" ",microtime());
    return (((float)$usec/1000) + (float)$sec);
}
?>


Message Edited by Forbidden on 08-07-2008 07:55 AM

Message Edited by Forbidden on 08-07-2008 09:11 AM

Message Edited by Forbidden on 08-11-2008 05:10 AM
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

Message Edited by pcotro on 11-08-2007 12:43 PM

  • November 08, 2007
  • Like
  • 0