Loading...
Page tree
Skip to end of metadata
Go to start of metadata


Description

Use this instruction if forms on the website are connected via the Contact Form 7 plugin.

After sending the lead from the from, the lead can be sent to CRM by email with the information about the number of visit from Roistat.

Configuration

Log in to your WordPress account and open Admin panel → Contact Form 7 → Form name → Change

1) In the Form template, add the following hidden form, where the cookie with Roistat visit number will be saved:  

<input type="hidden" name="roistat-promo-code"> 


2) The hidden form is filled in by the following script:

<script>
function getCookie(name) {
 var cookie = " " + document.cookie;
 var search = " " + name + "=";
 var setStr = null;
 var offset = 0;
 var end = 0;
 if (cookie.length > 0) {
        offset = cookie.indexOf(search);
 if (offset != -1) {
            offset += search.length;
 end = cookie.indexOf(";", offset)
            if (end == -1) {
                end = cookie.length;
 }
            setStr = unescape(cookie.substring(offset, end)); //После отправки заявки из формы
 }
    }
    return(setStr);
}

(function(d){
    setTimeout(function(){
        document.getElementsByName('roistat-promo-code')[0].value = getCookie('roistat_visit');
 }, 1000);
})(document);
</script>

This script also be placed in the website pages after the Roistat tracking code before the </body> tag. 

3) To transmit the value of the promo-code, you can also add the following parameter in the message template:

[roistat-promo-code]

4) Use the hook in the wpcf7_before_send_mail module to process the deal and send it to Roistat:

function wpcf7_modify_this($WPCF7_ContactForm) {
	// See the code of this script in your CRM instruction in the Configure the automatic transfer of leads to CRM step
	// The example for amoCRM – http://help-en.roistat.com/display/Eng/AmoCRM#AmoCRM-Step3.ConfiguretheautomatictransferofleadstoCRM
	// The promo code will be available in the $_COOKIE array by roistat_visit key
	// For example: $roistatVisitId = array_key_exists('roistat_visit', $_COOKIE) ? $_COOKIE['roistat_visit'] : "unknown";
}
add_action("wpcf7_before_send_mail", "wpcf7_modify_this");

How to configure the ContactForm7 as an individual plugin

To integrate ContactForm7 with Roistat as an individual plugin:

1. Create the roistat-contact-form-7-integration folder in the wp-content\wp-content\plugins catalogue.  
2. Create the roistat-contact-form-7-integration.php file in the roistat-contact-form-7-integration catalogue.  
3. Add this code to the file:

<?php
/*
Plugin Name: ROIstat CF7 integration
Plugin URI:
Description:
Version: 0.1
Author:
Author URI:
License: GPL2
*/


function wpcf7_modify_this( $WPCF7_ContactForm ) {
    // Transfer of data to CRM
   $roistatData = array(
      'roistat' => isset($_COOKIE['roistat_visit']) ? $_COOKIE['roistat_visit'] : null,
      'key'     => 'SECRET_KEY', // Replace SECRET_KEY to standard key 
      'title'   => 'New lead from the website', // Permanent value
      'comment' => isset($_POST['your-message']) ? $_POST['your-message'] : null, // For 'your-message' field
      'name'    => isset($_POST['your-name'])    ? $_POST['your-name'] : null, // For 'your-name' field
      'email'   => isset($_POST['your-email'])   ? $_POST['your-email'] : null, // For 'your-email' field
      'phone'   => null, // If there is no value
      'fields'  => array(
      // Array of additional fields (if needed)
    // Example of usage:
        "price" => 123, // Budget field in CRM
        "responsible_user_id" => 3, // Responsible for deal
        "1276733" => "Text", // Filling the field with ID 1276733
    // To get more information about additional fields, contact our support service
        "charset" => "Windows-1251", // Server converts the values of fields from the specified UTF-8 encoding
      ),
   );
   file_get_contents("https://cloud.roistat.com/api/proxy/1.0/leads/add?" . http_build_query($roistatData));
}
add_action("wpcf7_before_send_mail", "wpcf7_modify_this");

?>

4. Add the ContactForm7 to the plugin list in the admin panel of the website. 

An alternate way of adding the ContactForm7 to the plugin list 

  1. Create the roistat-contact-form-7-integration folder in the wp-content\wp-content\plugins catalogue. 
  2. Add the roistat.php file from this archive to the roistat-contact-form-7-integration folder.
  3. Add the ContactForm7 to the plugin list in the admin panel of the website. 
  • No labels