ClickTale Support Forums

All times are UTC - 6 hours



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu May 03, 2007 10:49 pm 
Offline

Joined: Mon Dec 04, 2006 5:30 pm
Posts: 18
This is outdated. See http://forum.clicktale.net/v ... .php?p=927

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). Thanks to Arik for pointing me in the right direction.

You'll notice that we include the clicktale source locally; you'll probably want to change that to however you've got it configured, and I believe the ClickTale() function also needs to be changed to match your account.

Code:
function get_clicktale_footer() {
   $request_url = $_SERVER["REQUEST_URI"] ;
   $request_url = ltrim($request_url, "/") ; //get rid of initial slash, since get_base_url always includes a trailing slash
   $current_url = get_base_url() . $request_url ; //my function. returns, for example, "http://www.supportourribbons.com/"
   $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, 'PHPSESSID=' ) && !empty($sid) ) {
      if( strstr( $current_url, '?' ) ) {
         $current_url .= "&PHPSESSID=" . $sid ;
      }
      else {
         $current_url .= "?PHPSESSID=" . $sid ;
      }
   }

   return "<!-- ClickTale Bottom part -->
<div id='ClickTale' style='display: none;'></div>
<script src='[!YOUR CLICKTALE PATH!]/WRa.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') {
   ClickTaleFetchFrom='$current_url' ;
   ClickTale([!YOUR PROJECT ID!],[!YOUR RATIO!]);
}
</script>
<!-- ClickTale end of Bottom part -->" ;
}

function get_base_url() {
   if( $_SERVER['SERVER_PORT'] == "443" ) {
      $abs_path = "https://" ;
   }
   else {
      $abs_path = "http://" ;
   }

   $dirname = dirname($_SERVER['PHP_SELF']) ;
   $dirname = str_replace("\\", "/", $dirname) ;
   $abs_path .= $_SERVER['HTTP_HOST'] . $dirname ;
   if( $abs_path[strlen($abs_path)-1] != '/' )
      $abs_path .= '/' ;
   return $abs_path ;
}   


The get_clicktale_header() function is left as an exercise to the reader :) I apologize if there are any errors in the code; I had to make some quick edits to remove some site-specific stuff.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 4:36 am 
Offline
Site Admin

Joined: Fri Jul 21, 2006 2:39 pm
Posts: 1206
Location: Israel
Jake, it looks great.

I changed your post in some places to make the code more general. I also changed it to represent the default non-SSL enabled mode.
If your account is SSL enabled then change get_clicktale_footer to return:

Code:
return "<!-- ClickTale Bottom part -->
<div id='ClickTale' style='display: none;'></div>
<!--[if IE]><script defer='defer' src='[!YOUR CLICKTALE PATH!]/WRDefer.js' type='text/javascript'></script><![endif]-->
<script src='[!YOUR CLICKTALE PATH!]/WRa.js' type='text/javascript'></script>
<script type='text/javascript'>
if(typeof ClickTale=='function') {
   var ClickTaleSSL=1;
   ClickTaleFetchFrom='$current_url' ;
   ClickTale([!YOUR PROJECT ID!],[!YOUR RATIO!]);
}
</script>
<!-- ClickTale end of Bottom part -->" ;


Let us know if this works for you or not.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 05, 2007 8:10 am 
Offline
Site Admin

Joined: Fri Jul 21, 2006 2:39 pm
Posts: 1206
Location: Israel
In some cases your PHP session cookie might have a different name than "PHPSESSID".

For example, if you are using osCommerce, your cookie is called "osCsid".
Various programs exist that show a list of cookies for a site. You can use those to find your cookie name or email supp...@clicktale.com and we will help you with that.

Arik.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group