====== Talk:Projects:Google Analytics for DokuWiki ====== * Start all subtopics using H2. (Heading 2.) ===== How to use Analytics plugin? ===== - Download and install the plugin in lib/plugins (you should have a folder like this: lib/plugins/googleanalytics) - Copy and paste the below code into main.php (anywhere between and ) which is in lib/tpl/monobook folder - Login to your Google analytics account and add the URL of your wiki - Copy the tracking code (e.g., UA-1234-1) - Login to your wiki and go to admin. click on Google Analytics then paste the tracking code into the field. - Wait a few minutes and you should be getting data in your google analytics account. ===== Wrong version info ===== The last version of the plugin identifies as 2007-02-23 instead of 2007-03-11 in getInfo(). Should be fixed. ===== Code Location in Template ===== Hi! This is a really handy little plugin, thanks for putting it together. I hope this isn't getting into too much semantics, but I am a little confused about the location of the code in the template. The plugin instructions say to place the code in the section (and the monbook template has it pre-placed there of course). This then results with both the google 2. I install the plugin and put the code in the main.php page of my monobook 3. I go to my ACL page, and would put the code, but it is very small form. So, what do I have to do with the google six raw code? Where the mistake? Best. --- //[[hirzel75[et]hotmail[dot]com|hirzel75]]// \\ **AUTOREPLY**\\ From Terence's holy Words: There are two different "codes" that people usually confuse... \\ 1. There's the HTML code that google analytics gives you: 2. And then there's the unique ACCOUNT code within *that* HTML code: _uacct = "...."; Which actually says something like this: _uacct = "UA-12345"; The reason that the code field is so small in the plugin, is that it is looking simply for: UA-12345 Or whatever your unique "code" is.) The plugin generates the HTML code, given that you provide an ACCOUNT code. So the answer to question 3 is: **paste only UA-12345 ** --- //[[hirzel75[et]hotmail[dot]com|hirzel75]]// ===== Any way to extend the plug-in to also track media files, downloads and external links ===== >The plug-in seems to work well for the DokuWiki pages. What I would like to have on top is: whenever a user clicks on a link that does not lead to a wiki page but rather to a media file or download or to an external link that that gets tracked as well. (Olaf) That's way beyond the scope of this plugin. Here's just some thoughts on why... * Google Analytics itself is written by Google, not me. * This plugin just makes it easier to integrate Google Analytics with your site. * **Google Analytics is in JavaScript.** * There's only so much you can do with JavaScript * **Runs on the client side, not the server side** * Much of what you want would be reliant on the server side * You can't run JavaScript from non-HTML documents, so... * Direct links to files from other sites cannot be tracked via this plugin. * **Google Analytics already tracks outgoing links.** These are just a few reasons that come to mind; the primary thing is you'd want something that runs **server side**, which this plugin really doesn't do. I'd almost say you could modify the [[:projects:referrers for dokuwiki]] plugin to do this, but in reality, I doubt DokuWiki is flexible enough for you to track media files (or downloads) via a plugin. For this alone you'd need to modify DokuWiki's source. Otherwise external links are already "tracked" by Google Analytics somewhat (I believe they call them "bounces" but I'm not sure.) I say somewhat because it's not really as if they give you a verbose listing of every outgoing link or every incoming link... (Which is why I wrote the [[:projects:referrers for dokuwiki]] plugin.) Hope that helps. --- //[[tjgrant@tatewake.com|Terence J. Grant]] 02/22/2007 20:09// Hi Terence: just to make this clear - I am not complaining! ;-> WRT to your reply: I have to admit I am far from being a DokuWiki or PHP expert. Nevertheless, the links for media/downloads must be encoded somehow somewhre in the DokuWiki code, and the idea would be specialize the creation of these links such that they include an onClick call to a Google Analytics JavaScript call. We have already done that for a website that has its own way of creating download links. At the moment a guy who does PHP and DokuWiki programming for us is chewing on how to meet this need in the context of our DokuWiki sites. Once he has figured out how to do it I will be more than happy to share his findings here. So maybe you might be in a position to extend the scope of your nice plug-in should you feel like it. (Olaf) Ah, I see; you're correct in this, it should be possible to track additional things via onClick. I'll look into syntax plugins and see how easy it would be to integrate this in. I can't really give you a time line on this though since I've not done syntax plugins before. --- //[[tjgrant@tatewake.com|Terence J. Grant]] 02/23/2007 17:17// ===== GeoURL for DokuWiki ===== Hi! I have made a DokuWiki plugin based on your. GPLed, [[http://www.burghardt.pl/wiki/software/geourl_for_dokuwiki|GeoURL for DokuWiki]]. Regards, --KB ===== little bug ===== line 39, code.php should be changed to: if (is_writable($ga_file) || is_writable(dirname(__FILE__))) is_writable($ga_file) will fail if the file does not exist, although the directory is writeable. http://de2.php.net/manual/en/function.is-writable.php seems that function is buggy in general :\ \\ contact: [[bernd@bzed.de]] ===== google adsense ===== I've grabbed your code and made [[http://bzed.de/code/dokuwiki/googleads]] out of it. While doing it I've realized, that you could improve the analytics plugin by adding addslashes/stripslashes at the appropriate places to stop people from destroying their config file by entering ' accidentally. --- [[bernd@bzed.de|bzed]] 2007-03-14 =====Which file to add the code to?===== >Which file should I add the code to? I try adding it to footer.html but I cannot save it as .html and if I save it as .php, the template does not work. Thanks for your help. Add the code to main.php, somewhere between the and tags. --- //[[tjgrant@tatewake.com|Terence J. Grant]] 05/27/2007 12:50// ===== little bug - count admin ===== line 63, code.php should be changed from: if ($ga_settings['dontcountadmin'] && $_SERVER['REMOTE_USER'] == conf['superuser']) return; to: if ($ga_settings['dontcountadmin'] && $INFO['isadmin'] = 1 ) return; contact: [[vaclav@koranek.eu]] ===== configuration file ===== line 13, 37 in code.php : you sould use **//$ga_file = DOKU_CONF.'ga_pref.php';//** to be able to use the plugin in differents wikis with differents configurations. contact [[thomas.mortagne@gmail.com]] ===== Makin' it configurable ===== Hi, upon installing your plugin, I have edited your //ga_google_analytics_code// function so that it includes: '); ptln('var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");'); ptln('document.write(unescape("%3Cscript src=\'" + gaJsHost + "google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E"));'); ptln(''); ptln(''); } else if ($ga_tracker == 'UseOld') { ptln(''); ptln(''); } } } ?> Obviously this allows a user to choose the kind of google analytics tracker he wants to use. I actually use the old one :-). contact [[miki.antena@gmail.com]]