• Resolved Collabrax

    (@collabrax)


    I am using Contact Form 7 and Analytics by Found. I’ve added the following code the site’s main function.php file that takes the form information and sends it into salesforce.com and it works. I need to send the Analytics information as well. Can you help with get this information into here?

    add_action( 'wpcf7_before_send_mail', 'my_conversion' );
    function my_conversion( $cf7 )
    {
      $email = $cf7->posted_data["your-email"];
      $first_name  = $cf7->posted_data["your-firstname"];
      $last_name  = $cf7->posted_data["your-lastname"];
      $phone = $cf7->posted_data["your-phone"];
      $state = $cf7->posted_data["state-323"];
      $message  = $cf7->posted_data["your-message"];
      $jobtype  = $cf7->posted_data["service-796"];
      $recordtype = "012400000001B1m";
      $lead_source = $cf7->title;
    
      $post_items[] = 'oid=XXXXXXX';
      $post_items[] = 'first_name=' . $first_name;
      $post_items[] = 'last_name=' . $last_name;
      $post_items[] = 'email=' . $email;
      $post_items[] = 'phone=' . $phone;
      $post_items[] = 'state=' . $state;
      $post_items[] = '00N40000002TVvT=' . $message;
      $post_items[] = '00N40000002TIeH=' . $jobtype;
      $post_items[] = 'recordType=' . $recordtype;
      $post_items[] = 'lead_source=' . $lead_source;
    
      if(!empty($first_name) && !empty($last_name) && !empty($email) )
      {
        $post_string = implode ('&', $post_items);
        // Create a new cURL resource
        $ch = curl_init();
    
        if (curl_error($ch) != "")
        {
          // error handling
        }
    
        $con_url = 'https://www.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
      }
    }

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    http://wordpress.org/extend/plugins/contact-form-7-analytics-by-found/

Viewing 1 replies (of 1 total)
  • Plugin Author Found

    (@found)

    Hi Collabrax,

    As your code suggests you should do something like
    $analytics = $cf7->posted_data[“analytics”];

    the posted_data key should be the name of the Found field you chose when you created the form.

    I hope this is useful,

    Thanks,
    Dora

Viewing 1 replies (of 1 total)
  • The topic ‘Help getting Analytics information in main site function.php file’ is closed to new replies.