本稿は「plugin:googleanalytics [DokuWiki]」([[https://www.dokuwiki.org/plugin:googleanalytics|リンク]])の記事の拙訳版です。 ====== Google Analytics for DokuWiki ====== ---- plugin ---- 説明 : Google Analyticsのコードを埋め込む事で、あなたのサイトへの訪問者の記録を行うことができます。 作成者: Terence J. Grant メール: tjgrant@tatewake.com タイプ: action 最終更新日: 2009-05-25 compatible : (current version) 依存するプラグイン: 競合するプラグイン: 似ているプラグイン: piwik, referrers タグ : google, statistics, embed ダウンロード   :http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-googleanalytics/googleanalytics-stable.tar.gz ソースリポジトリ :https://github.com/tatewake/dokuwiki-plugin-googleanalytics ---- ===== License ===== * **Author:** [[tjgrant@tatewake.com|Terence J. Grant]] * **License:** [[http://www.opensource.org/licenses/gpl-license.php|GNU GPL v2]] * **Last Update:** 2009-05-25 * **Donate:** [[https://www.paypal.com/xclick/business=tjgrant%40tatewake.com&item_name=Google%20Analytics%20for%20DokuWiki%20Donation&no_shipping=1&no_note=1&tax=0¤cy_code=USD&lc=US|Click here.]] It's not required, but please consider linking to [[googleanalytics|this page]] or the main page from your site if you like this product. ===== Download ===== Before downloading or using this product, make sure you __**understand and accept**__ the terms of the [[#license]]. After downloading, make sure to follow the [[#install]] instructions or [[#upgrading]] instructions below; trust me, they're worth reading. * This is the **latest version**, compatible with **The Latest DokuWiki**: * Latest Version: {{http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-googleanalytics/googleanalytics-stable.tar.gz}} - May 25, 2009 * Github URL: [[http://github.com/tatewake/dokuwiki-plugin-googleanalytics]] * Older downloads are available on request only. **Note: http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-googleanalytics/googleanalytics-stable.tar.gz always points to the latest stable version!** ===== Installation ===== Use the plugin manager to install, or... - [[#download]] the tarball/zip-file - unpack it into ''/lib/plugins/'' - login as admin and change the plugin in the configuration manager - Google Analytics requires additional configuration for best use with DokuWiki (e.g., site search and goals). See [[http://en.seowiki.info/best_practices/seo_optimized_dokuwiki/integration/google_analytics|Google Analytics integration for DokuWiki]] for details **using git:**\\ % cd /lib/plugins/ % git clone git://github.com/tatewake/dokuwiki-plugin-googleanalytics.git googleanalytics **Debian install (or probably any other distribution):** # cd /usr/share/dokuwiki/lib/plugins/ # wget http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-googleanalytics/googleanalytics-stable.tar.gz # tar -xvzf googleanalytics-stable.tar.gz # chown -Rv 33 googleanalytics/ **Note: http://cloud.github.com/downloads/tatewake/dokuwiki-plugin-googleanalytics/googleanalytics-stable.tar.gz always points to the latest stable version!** ===== About ===== This tool allows you to set a code for use with [[wp>Google_Analytics|Google Analytics]], which allows you to track your visitors. Set the options for this plugin via the **Configuration Settings** menu from the DokuWiki admin menu. (It will be near the bottom of the page.) {{:projects:ga-settings.png}} ===== Upgrading ===== To upgrade, remove the original lib/plugins/googleanalytics folder, and install the new version as instructed above. You may wish to make a note of your google analytics code first though. ===== What's New ===== ==== May 25, 2009 ==== * Plugin is now an **action plugin** that requires no additional PHP code modification. Thanks to [[izmmishao5@gmail.com|Mikhail I. Izmestev]] for this fix. ==== June 27, 2008 ==== * Fixed bug with tracking code * Added better check for admin users (removed old 'superuser' check) Thanks to [[david@ordal.com|David Ordal]] for these fixes. ==== June 10, 2008 ==== Updated to use the new Javascript library for Google Analytics. Thanks to Geoff W. and RJS for the contribution. ==== March 11, 2007 ==== * Fixed minor bug for "is_writable", thanks to [[bernd@bzed.de]] ==== February 23, 2007 ==== * HTTPS support by [[matjaz.slak@atol.si|Matjaz Slak]] ==== February 15, 2007 ==== * Arabic translation, thanks to [[hali83@cec.sy|M. Bashir Al-Noimi]] for this. ==== August 20, 2006 ==== * Initial release ====== Discussion ====== * 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. :!: For latest version your don't need add any php code, see [[#May 25, 2009|above]]\\ -- //[[quabug+dokuwiki@gmail.com|quabug]]// 2010/11/12 ===== 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 [[:plugin:referrers]] 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 [[:plugin:referrers]] 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]] ===== Polish Translation ===== (2011/12/30)