Can Kampyle automatically recognize my site's users?

FAQ about Kampyle's Website Feedback Analytics application.

Can Kampyle automatically recognize my site's users?

Postby kampyle » Wed Apr 02, 2008 1:19 pm

Kampyle User Integration

The Kampyle system enables you to integrate your current's site users with the Kampyle management application in order to display your users' details while browsing your feedbacks on Kampyle.
When using the User-Integration feature, your users will not be asked to enter their email after submitting a feedback, and the Kampyle system will automatically match the submitted feedback to the additional details supplied by your system.
NOTE: this feature is limited to Premium account owners only (Bronze accounts and higher).

Kampyle offers you two options to integrate your users with the Kampyle system:
  1. First option: The user's details will be sent to the Kampyle system via GET.
    Note that in this case the user might be able to see the parameters that you send to Kampyle.
  2. Second option: The user's details will be sent to the Kampyle system via cURL, using an external file.
    In this case the user will not be able to see the parameters that you send to Kampyle.

*The first option is simpler to implement, the second option requires cURL or a similar library.

Step 1: The Data Sent to Kampyle
The Kampyle system is able to receive 4 details regarding your website user:
  • The user's name - "u_disp" - The name that will be displayed in the Kampyle management application
  • The user's E-Mail - "u_email"
  • A unique id for the user - "u_id" - This will allow the system to differentiate between different users (mandatory, case sensitive)
  • An indication whether to or to not send a "Thank You" mail after receiving a feedback - "u_notify_email" - 1 for yes, 0 for no.
In addition, every integration request must contain a secret security code ("u_code") used to make sure that the request is authentic.

The security code is calculated by concatenating your Kampyle private key to the user's id and hashing the result using the SHA256 algorithm.
To find your Kampyle Private Key, enter the management application and navigate to the Feedback Form Customization page. On the bottom of the page you will find your Private Key. Please note: Your Kampyle Private Key is case sensitive.

e.g:
Your Kampyle Private Key is: Kampyle_111_sdsadwefwef.html
You want to calculate the security code for: User1
To calculate your security code, concatenate your Private Key to the username:

In PHP:
Code: Select all
$private_key = 'Kampyle_111_sdsadwefwef.html';
$u_id = 'User1';
$u_code = hash('sha256', $private_key.$u_id);


In ASP:
Code: Select all
// class definition
using System;
using System.Text;
using System.Security.Cryptography;

namespace myCryptography
{
      public class Hash
      {
            public Hash()
            {
                  //
                  // TODO: Add constructor logic here
                  //
            }
     

        public static string MakeHashSHA256(string str)
        {
            byte[] data = Encoding.UTF8.GetBytes(str); 
            byte[] result;
            string resultStr = string.Empty;
            HashAlgorithm sha256 = new SHA256Managed();
            result = sha256.ComputeHash(data);           

            resultStr = BitConverter.ToString(result).Replace("-", "").ToLower();

            return resultStr;
        }

        public static string GetKampyleFeedbackUcode(string userID)
        {
            string key =  string.Format(  "Kampyle_111_sdsadwefwef.html{0}",userID) ;   //Write your private key
           
            return  MakeHashSHA256(key);
        }
      }
}
// end class definition

string  ucode= myCryptography.Hash.GetKampyleFeedbackUcode ("User1"); //Call the function with your user id


The result will be the security code, unique for that specific user.

For more information about the SHA256 Algorithm, visit:
http://en.wikipedia.org/wiki/SHA_hash_functions

Step 2: Sending the Data to Kampyle

First Option: Sending the User's Details Via GET
You may send the user's details to Kampyle via GET using two methods:
  1. Using a Javascript Object (recommended)
  2. Adding the parameters directly to the Feedback Form URL

To send the data to Kampyle using a Javascript Object, simply add the following code to your webpage AFTER the "k_button.js" script is included by your standard Kampyle Button code.
e.g:
The Kampyle standard button code:
Code: Select all
<!--Start Kampyle Feedback Form Button-->
<div id="k_close_button" class="k_float kc_bottom kc_right"></div>
<div>
   <a href="http://www.kampyle.com/feedback_form/ff-feedback-form.php?site_code=123456&amp;form_id=123&amp;lang=en" target="kampyleWindow" id="kampylink" class="k_float k_bottom k_right" onclick="k_button.open_ff();return false;">
      <img src="http://cf.kampyle.com/en-orange-corner-low-right.gif" alt="Feedback Form"/>
   </a>
</div>
<script src="http://cf.kampyle.com/k_button.js" type="text/javascript"></script>
<!--End Kampyle Feedback Form Button-->

The User Integration addition:
Code: Select all
<script type="text/javascript">
k_button.extra_params =
{
"u_code": '95630200f21510e339700781aa18eee9d797fa93702de6799a91f676efbf8522',
"u_id": "registered_user_2048",
"u_disp": "User 1",
"u_email": "user1@kampyle.com",
"u_notify_email": 1
}
</script>


To send the data using the Feedback Form's URL, append the extra parameters to the Feedback Form's URL:

Code: Select all
http://www.kampyle.com/feedback_form/ff-feedback-form.php?site_code=123456&form_id=123&lang=en&u_code=95630200f21510e339700781aa18eee9d797fa93702de6799a91f676efbf8522&u_id=registered_user_2048&u_disp=User%201&u_email=user1@kampyle.com&u_notify_email=1


Second Option: Sending the User's Details Via cURL
In this method, you will use an extra page in order to send the user's data. The data will be sent via POST and therefore will be invisible to the users.

A PHP example:
Code: Select all
<?php
//get standard Kampyle parameters:
$url = $_GET['url'];
$form_id = $_GET['form_id'];
$lang = $_GET['lang'];

$form_url = "http://www.kampyle.com/feedback_form/ff-feedback-form.php";
$site_code = '9444465';
$private_key = 'Kampyle_6_444444CeO.html';
$u_id = 'registered_user_2048';

//Calculate security code
$u_code = hash('sha256', $private_key.$u_id);

//Optional parameters you can send
$u_disp = "User1";
$u_email = 'user1@kampyle.com';
$u_notify_email = '1';

//Use CURL module (this module is available for free installation in most languages - http://curl.haxx.se/)
//Another option is to use any other HTTP library you have

$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, $form_url);
curl_setopt ($curl, CURLOPT_POST, 1);
$post_fields = "site_code=$site_code&url=$url&u_id=$u_id&u_code=$u_code&u_disp=$u_disp&u_email=$u_email&u_notify_email=$u_notify_email&lang=$lang";

curl_setopt ($curl, CURLOPT_POSTFIELDS, $post_fields);
curl_exec ($curl);

curl_close ($curl);

return;
?>



After You upload the new page to your website, simply link to it instead of linking directly to the Kampyle Feedback Form.
The old code:
Code: Select all
<!--Start Kampyle Feedback Form Button-->
<div id="k_close_button" class="k_float kc_bottom kc_right"></div>
<div>
   <a href="http://www.kampyle.com/feedback_form/ff-feedback-form.php?site_code=123456&amp;form_id=123&amp;lang=en" target="kampyleWindow" id="kampylink" class="k_float k_bottom k_right" onclick="k_button.open_ff();return false;">
      <img src="http://cf.kampyle.com/en-orange-corner-low-right.gif" alt="Feedback Form"/>
   </a>
</div>
<script src="http://cf.kampyle.com/k_button.js" type="text/javascript"></script>
<!--End Kampyle Feedback Form Button-->


The new code:
Code: Select all
<!--Start Kampyle Feedback Form Button-->
<div id="k_close_button" class="k_float kc_bottom kc_right"></div>
<div>
   <a href="http://www.mySite.com/integrate_with_kampyle.php?lang=en&form_id=123" target="kampyleWindow" id="kampylink" class="k_float k_bottom k_right" onclick="k_button.open_ff();return false;">
      <img src="http://cf.kampyle.com/en-orange-corner-low-right.gif" alt="Feedback Form"/>
   </a>
</div>
<script src="http://cf.kampyle.com/k_button.js" type="text/javascript"></script>
<!--End Kampyle Feedback Form Button-->



The cURL library is available for most languages on http://curl.haxx.se/

--------------------------------------------------------------------------------------------------------------

In both cases, you may send only the user's Id and security code, all other fields are optional.
Please Note:
  1. Kampyle will not use the received information for any purpose except displaying it in the Management Application
  2. It is recommended not to send confidential information
  3. To check your Security Code calculation, you may use the Kampyle Security Code generator.


IMPORTANT NOTE:
In case the u_id or u_email contains special characters such as one of the following: ,/?:@&=$#
It is suggested to replace the special character according the following list, otherwise the special character will be replaced with a space.

, = KAMP_SPEC2C
/ = KAMP_SPEC2F
? = KAMP_SPEC3F
: = KAMP_SPEC3A
@ = KAMP_SPEC40
& = KAMP_SPEC26
= = KAMP_SPEC3D
$ = KAMP_SPEC24
# = KAMP_SPEC23

So, if you are using PHP, your code will look like:
Code: Select all
      $u_id = 'james,abram';
      $u_code = hash('sha256', $private_key.$u_id);
      $u_id = str_replace(',', 'KAMP_SPEC2C', $u_id);
      //$u_id = 'jamesKAMP_SPEC2Babram@sample.com'; //This one should be sent to kampyle, and will be fixed in Kampyle
     
      $u_email = 'james,abram@sample.com';
      $u_email = str_replace(',', 'KAMP_SPEC2C', $u_email);


For assistance in implementing this feature, don't hesitate to contact the Kampyle Support Team.
kampyle
Site Admin
 
Posts: 109
Joined: Tue Feb 26, 2008 5:17 am

Return to Kampyle for Websites FAQs

Feedback Form