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

Leave a Reply

Related Posts: You may like

Contact Form 7 Redirect to Thank You Page

How to Validation Business Email in Contact Form 7 WordPress

How to Create and get WordPress Custom Field

How to add post from frontend in wordpress without plugin

PHPKIDA Offering Free Tools:

INSTA DOWNLOADER

Download Instagram Videos & Photos.

Download Now

CURRENCY CONVERTER

Real Time Currency Converter

Convert Now

ROBOST.TXT GEN.

Robots.txt File Creater

Create Now

HTML MINIFIER

Compress yout HTML Code

Minify Now

CSS MINIFIER

Compress yout CSS Code

Minify Now

JAVASCRIPT MINIFIER

Compress yout JavaScript Code

Minify Now

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.