PHP integration code
The instructions on this page are intended for self service and online accounts.
Enterprise customers should contact their account managers for integration support.
The only reason to use this code is if you are unable to install a binary module on your site.
This is an up to date version of the integration code which is based on work done by Jake from Support Our Ribbons.
Instructions
If your site uses cookie-based sessions, you may have noticed that ClickTale is unaware of any session-based stuff that's happening. So this is a little function for overriding the URL that ClickTale fetches from so it is sure to include the current session id. It's intended for people using PHP's built-in session functions (e.g. $_SESSION).
You'll notice that we include the ClickTale source locally; if you like you can save the code in an external include file. You will need to modify the parameters of the ClickTale() function to reflect the parameters of your account as well as update the path to the recording script. To fill-in the missing information compare the code below with the code that was generated for you by the "Script Generator".
<?
function get_clicktale_footer() {
$current_url = get_base_url();
$sid = session_id() ;
//if the session id is set, and not included in the current URL,
//append it to the current URL
if( !strstr( $current_url, session_name().'=$sid' ) && !empty($sid) ) {
$fetch_from = "ClickTaleFetchFrom='$current_url" ;
if( strstr( $current_url, '?' ) )
$fetch_from .= "&" ;
else
$fetch_from .= "?" ;
$fetch_from .= session_name()."=$sid';" ;
}
else
$fetch_from = "";
return "<!-- ClickTale Bottom part -->
<div id='ClickTale' style='display: none;'></div>
<script src='[!YOUR CLICKTALE PATH!]/WRb.js' type='text/javascript'></script>
<script type='text/javascript'>
//This is where everything pays off.
//Update the URL clicktale fetches from:
if(typeof ClickTale=='function') {
$fetch_from
ClickTale([!YOUR CLICKTALE PARAMETERS!]);
}
</script>
<!-- ClickTale end of Bottom part -->" ; // update your values here based on the script generated.
// Note the parameters to ClickTale call and the url. Keep other syntax and the line "$fetch_from" as-is.
}
function get_base_url() {
if( $_SERVER['SERVER_PORT'] == "443" )
$abs_path = "https://" ;
else
$abs_path = "http://" ;
$abs_path .= $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; //$_SERVER["REQUEST_URI"] ;
if( !empty($_SERVER['QUERY_STRING']) )
$abs_path .= '?' . $_SERVER['QUERY_STRING'];
return $abs_path ;
}
function get_clicktale_header() {
return "<!-- ClickTale Top part -->
<script type='text/javascript'>
var WRInitTime=(new Date()).getTime();
</script>
<!-- ClickTale end of Top part -->" ;
}
//echo get_clicktale_header(); // call after <BODY>
//echo get_clicktale_footer(); // call before </BODY>
?>
What is left now is to echo the result of the PHP functions get_clicktale_header() and get_clicktale_footer() near your body and /body tags to finish the integration.
If you have generated a SSL code with the generator you will need to do some extra copy-pasting to make your include.