我正在通过WPCF7跟踪AdWords转化。由于on_sent_ok不再起作用,因此我找到了一种解决方法:
// Contact Conversion-Tracker
function mycustom_wp_footer() {
?>
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = 'example.com./thank-you/';
}, false );
</script>
<?php
}
现在我的functions.php中有一个函数,我通过wpcf7将请求发送到salesforce:
// Lead 2 Salesforce
add_action( 'wpcf7_before_send_mail', 'editData' );
function editData( $cf7 ) {
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
$posted_data = $submission->get_posted_data();
$first_name = $posted_data["Vorname"];
$last_name = $posted_data["Nachname"];
$Tel = $posted_data["Tel"];
$mobile = $posted_data["mobile"];
$email = $posted_data["email"];
$message = $posted_data["message"];
$post_items[] = 'oid=00000000000';
$post_items[] = 'first_name=' . $first_name;
$post_items[] = 'last_name=' . $last_name;
$post_items[] = 'email=' . $email;
$post_items[] = 'phone=' . $Tel;
$post_items[] = 'mobile=' . $mobile;
$post_items[] = 'description=' . $message;
$post_items[] = 'lead_source=Contact form';
$post_items[] = 'company=not there';
$post_items[] = 'Anliegen__c=Contact';
$post_items[] = 'Work together';
$post_string = implode ('&', $post_items);
// Create a new cURL resource
$ch = curl_init();
if (curl_error($ch) != "")
{
// error handling
}
$con_url = 'salesforce.com/servlet/servlet.WebToLead?
encoding=UTF-8';
curl_setopt($ch, CURLOPT_URL, $con_url);
// Set the method to POST
curl_setopt($ch, CURLOPT_POST, 1);
// Pass POST data
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_string);
curl_exec($ch); // Post to Salesforce
curl_close($ch); // close cURL resource
}}
// End Lead 2 Salesforce
现在这两个功能似乎无法正常使用。由于我在重定向发生的位置添加了第一个功能,因此不会将新的潜在客户添加到我的Salesforce。
谢谢。