08 Sep 2011

GoogleAnalytics and TikiWiki

Sat down this morning to integrate Google Analytics into a couple TikiWiki CMS based sites. ;Went down easily for the WPress based ones… Tikis took a little (very little) research. Here’s the trick, as found on TikiWiki’s documentation. (The option of including it in the Javascript field or in standard location worked well in TikiWiki 7.0.) Their first option of including it within literal tags and using the GoogleAnalytics Plugin didn’t work on my older TikiWiki (~6.1). ;Used the second answer and it worked perfectly. ;Place the following code in the Look & Feel tab under “Custom End of Code”:

<scripttype="text/javascript"\> ; ;var ;_gaq ;= ;_gaq ;|| ;[]; ; ;_gaq.push(['_setAccount', ;'UA-XXXXXXXX-1']); ; ;_gaq.push(['_trackPageview']); ; ;(function() ;{ ;  ; ;var ;ga ;= ;document.createElement('script'); ;ga.type ;='text/javascript'; ;ga.async ;= ;true; ;  ; ;ga.src ;= ;('https:' ;== ;document.location.protocol ;?'https://ssl' ;: ;'http://www') ;+ ;'.google-analytics.com/ga.js'; ;  ; ;var ;s ;= ;document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga, ;s); ; ;})();\</script\>{/literal}{else}{literal}\<script ;type="text/javascript"\> ; ;var ;_gaq ;= ;_gaq ;|| ;[]; ; ;_gaq.push(['_setAccount', ;'UA-XXXXXXXX-1']); ; ;_gaq.push(['_trackPageview']); ; ;_gaq.push(['_setVar', ;'ga_exclude']); ; ; ;(function() ;{ ;  ; ;var ;ga ;= ;document.createElement('script'); ;ga.type ;='text/javascript'; ;ga.async ;= ;true; ;  ; ;ga.src ;= ;('https:' ;== ;document.location.protocol ;?'https://ssl' ;: ;'http://www') ;+ ;'.google-analytics.com/ga.js'; ;  ; ;var ;s ;= ;document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga, ;s); ; ;})();\</script\>

Thanks for the clear documentation doc.tiki.org ;and give the CMS a try. It’s a nicely integrated CMS w/ wiki, blog, forums, etc. Source: ;PluginGoogleAnalytics | Documentation for Tiki Wiki CMS Groupware.