Skip to content

Using Clickheat with CakePHP

2008 July 17

The Clickheat software, rocks. Personally I use the plugin for phpMyVisites, but I could understand anyone adopting the standalone package too.

CakePHP layouts can be setup to automatically print the most sensible url in each page it loads. This concept will work with any visitor tracking software that has a page or url attribute that is manually assigned.
To learn how and see the code, continue reading.

In /views/layouts/default.ctp;

//determine whtehr to use url (which doesnt work on homepge ) or not.
if(empty($params['url']['url'])) {
	//we need to concat our own url
	//only append action if not 'info' pages ('index' is hidden in url, and should be hidden here)
	if($pageWeSee!=='info') $pageWeSee.='/'.$params['action'];
	//any parmaeterrs we should know about?
	foreach( $params['pass'] as $p){
	}//end for each
	//oh how sweet, a fully built url for us
<!-- phpmyvisites -->
<a href="" title="Free web analytics, website statistics"
onclick=";return(false);"><script type="text/javascript">
var a_vars = Array();
var pagename='<?php echo $pageUrl; ?>';
var phpmyvisitesSite = 94;
var phpmyvisitesURL = "";
<script language="javascript" src="" type="text/javascript"></script>
<object><noscript><p>Free web analytics, website statistics
<img src="" alt="Statistics" style="border:0" />
<!-- /phpmyvisites --> 
<script type="text/javascript" src=""></script><noscript><a href="">Free marketing tools</a></noscript><script type="text/javascript"><!--
clickHeatSite = 93;clickHeatGroup = '<?php echo $pageUrl; ?>';clickHeatServer = '';initClickHeat(); //-->

The first section of code determines whether to trust the ‘url’ parameter, or build the address from controller,action,id .

The phpmyvisites and clickheat scripts both make a php call to the completed $pageURL variable.

Leave a Reply

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS