How to track contact form 7 form in salesforce without plugin

How to track contact form 7 form in salesforce without plugin

Here we will show you how can you track your form data of contact form 7 into salesforce without using any plugin.

Here we are create function track_salesforce_leads() inside function.php

add_action( 'wpcf7_before_send_mail', 'track_salesforce_leads' );

function track_salesforce_leads(){
	$submission = WPCF7_Submission::get_instance();
	$data = $submission->get_posted_data();
	
	$remote_ip = $submission->get_meta( 'remote_ip' );
	$url = $submission->get_meta( 'url' );
	
	$ip = $data['_remote_ip'];
	$first_name = $data['your-name'];
	$last_name = $data['your-lastname'];
	$company = $data['your-company'];
	$phone = $data['your-phone'];
	$email = $data['your-email'];
	$city = $data['your-city'];
	$country = $data['your-country'];
	$state = $data['your-state'];
	$message = $data['your-message'];
	$title = $data['your-subject'];
	
	$post_items[] = 'oid=000000000'; // Replace this by your OID value
	$post_items[] = 'lead_source=Your Lead Value';
	$post_items[] = '00N90000006pnvV=' .$remote_ip;
	$post_items[] = 'URL=' .$url;
	$post_items[] = 'first_name=' . $first_name;
	$post_items[] = 'last_name=' . $last_name;
	$post_items[] = 'email=' . $email;
	$post_items[] = 'company=' . $company;
	$post_items[] = 'city=' . $city;
	$post_items[] = 'country=' . $country;
	$post_items[] = 'state=' . $state;
	$post_items[] = 'phone=' . $phone;
	$post_items[] = 'title=' . $title;
	$post_items[] = 'description=' . $message;
	
	if(!empty($first_name) && !empty($last_name) && !empty($email) && !empty($phone))
	{
		$post_string = implode ('&', $post_items);
		// Create a new cURL resource
		$ch = curl_init();
		$con_url = 'your sales force url';
		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
	}
}

Tags:
how to track contact form 7 salesforce crm, contact form 7 with salesforce, salesforce contact form wordpress, pardot contact form 7, brilliant salesforce, contact form salesforce plugin, contact form 7 api integration, caldera forms salesforce

About Author

My name is Mukesh Jakhar and I am a Web Application Developer and Software Developer, currently living in Jaipur, India. I have a Master of Computer Application in Computer Science from JNU Jaipur University. I loves to write on technology and programming topics. Apart from this, I love to travel and enjoy the beauty of nature.

Sign up for weekly update

Milkshake is almost ready. If you're interested in testing it out, then sign up below to get exclusive access.