Using Clickheat with CakePHP

July 17, 2008

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;

params; if(empty($params[‘url’][‘url’])) { //we need to concat our own url $pageWeSee=$params[‘controller’]; //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? $ps=“; foreach( $params[‘pass’] as $p){ $ps.=‘/’.$p; }//end for each $pageUrl=$pageWeSee.$ps; }else{ //oh how sweet, a fully built url for us $pageUrl=$params[‘url’][‘url’]; } ?>

[<!– var a_vars = Array(); var pagename=’<?php echo $pageUrl; ?>‘;

var phpmyvisitesSite = 94; var phpmyvisitesURL = “http://example.org/phpmyvisites/phpmyvisites.php"; //–>

Free web analytics, website statistics Statistics

](http://www.phpmyvisites.net/ “Free web analytics, website statistics”)

Free marketing tools

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.

Nifty tech tag lists fromĀ Wouter Beeftink | Page content generated from commit: 15a22e6