ClickTale Support Forums

All times are UTC - 6 hours



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: PHP Integration Code
PostPosted: Mon Nov 26, 2007 6:48 pm 
Offline
Site Admin

Joined: Fri Jul 21, 2006 2:39 pm
Posts: 1206
Location: Israel
[ This is an up to date version of the integration code which is based on work done by Jake from supportourribbons.com ]

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; 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".

Code:
<?
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 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-paste to make your include. Contact us if you can't manage and need help.

Regards,
Arik.


Top
 Profile  
 
 Post subject: Re: PHP Integration Code
PostPosted: Sat May 09, 2009 6:45 am 
Offline

Joined: Sat May 09, 2009 6:41 am
Posts: 1
Do you have any samples of this for .asp sites? Our site uses cookies for navigation and clicktale isn't capturing this information.


Top
 Profile  
 
 Post subject: Re: PHP Integraton Code
PostPosted: Sun May 10, 2009 1:02 am 
Offline
Site Admin

Joined: Fri Jul 21, 2006 2:39 pm
Posts: 1206
Location: Israel
stfrancis wrote:
Do you have any samples of this for .asp sites? Our site uses cookies for navigation and clicktale isn't capturing this information.


For classic ASP you could use our ClickTaleFetchFrom instruction combined with some programming on your site to pass the cookie value via the fetch URL. See examples of using ClickTaleFetchFrom here: viewtopic.php?f=5&t=187 and here: viewtopic.php?f=5&t=561

For ASP.NET you should use the ASP.NET integration module: viewtopic.php?f=5&t=423

Arik.


Top
 Profile  
 
 Post subject: Re: PHP Integraton Code
PostPosted: Wed Aug 19, 2009 1:10 pm 
Offline

Joined: Tue Aug 18, 2009 9:55 am
Posts: 5
Hi there,

I've integrated everything but I can't see anything in the dashboard. Do I need to open any special server ports or anything? I added a few echo commands to the clicktale scripts which worked so all looks ok apart from no recordings in the console. Do I have to wait any time?

In the code here,
"ClickTale([!YOUR PROJECT ID!],[!YOUR RATIO!]);" would become (for example)
ClickTale(6660,1);

However the "Get tracking code" function provides:

if(typeof ClickTale=='function') ClickTale(6660,1,"www02");

so is there not a third parameter missing?

Are there any debug modes I can switch on and do I have to edit WRb.js ?

Cheers
Dude


Top
 Profile  
 
 Post subject: Re: PHP Integraton Code
PostPosted: Wed Aug 19, 2009 1:45 pm 
Offline
Site Admin

Joined: Fri Jul 21, 2006 2:39 pm
Posts: 1206
Location: Israel
Hey,

Yes, you are missing the third parameter.
Based on what you specified, it should be "www02".

There is a debug mode which you can invoke. See: viewtopic.php?f=2&t=84

Let us know if it helps.
Arik.


Top
 Profile  
 
 Post subject: Re: PHP Integraton Code
PostPosted: Wed Aug 19, 2009 2:07 pm 
Offline

Joined: Tue Aug 18, 2009 9:55 am
Posts: 5
Hi Arik

Many thanks. I tried "'www02" but got an unexpected T string error.
So have changed to 'www02' but still nothing on dashboard.

The code now is:

return "<!-- ClickTale Bottom part -->
<div id='ClickTale' style='display: none;'></div>
<script src='http://s.clicktale.net/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(6664,1,'www02');
}

Many thanks for info on debug mode.

Cheers
Dude


Top
 Profile  
 
 Post subject: Re: PHP Integraton Code
PostPosted: Wed Aug 19, 2009 2:48 pm 
Offline
Site Admin

Joined: Fri Jul 21, 2006 2:39 pm
Posts: 1206
Location: Israel
Hi,

I can see new recording in your account. It seems that the code is working. However, in your side I can see that some of the pages in your process are POST pages.
Unfortunately POST pages are not supported by this method. They are supported with the PHP integration module, which requires PHP5.
Supporting PHP4 pages with POST is difficult. You can see an example here: viewtopic.php?f=5&t=561

Regards,
Arik.


Top
 Profile  
 
 Post subject: Re: PHP Integraton Code
PostPosted: Wed Aug 19, 2009 4:03 pm 
Offline

Joined: Tue Aug 18, 2009 9:55 am
Posts: 5
Hi Arik

Many thanks for your response.

Just to check, my code is 6664. The two visits I made in debug mode were recorded 100% but visits I make outside of debug mode do not seem to be recorded. Is this because of POST please?

Many thanks
Dude


Top
 Profile  
 
 Post subject: Re: PHP Integraton Code
PostPosted: Thu Aug 20, 2009 9:33 am 
Offline
Site Admin

Joined: Fri Jul 21, 2006 2:39 pm
Posts: 1206
Location: Israel
I can't see anything wrong with the integration.
Are you getting traffic to your page which isn't getting recorded?
Try to visit from a different pc and see if you are recorded.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 guests


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