<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Guy Rutenberg &#187; MediaWiki</title>
	<atom:link href="http://www.guyrutenberg.com/category/mediawiki/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.guyrutenberg.com</link>
	<description>Keeping track of what I do</description>
	<lastBuildDate>Wed, 16 Jun 2010 19:53:40 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tracking MediaWiki External Links Statistics using Google Analytics</title>
		<link>http://www.guyrutenberg.com/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/</link>
		<comments>http://www.guyrutenberg.com/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 16:06:44 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MediaWiki]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://guy.sikumuna.com/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/</guid>
		<description><![CDATA[When you track MediaWiki statistics, you usually track only internal page statistics, but tracking external links which leads out of your site is not some thing you can ignore. Unfortunately we probably can&#8217;t put actual tracking code in the pages linked to by our site&#8217;s external links. Fortunately we can track the actual clicks on [...]]]></description>
			<content:encoded><![CDATA[<p>When you track MediaWiki statistics, you usually track only internal page statistics, but tracking external links which leads out of your site is not some thing you can ignore. Unfortunately we probably can&#8217;t put actual tracking code in the pages linked to by our site&#8217;s external links. Fortunately we can track the actual clicks on those links that lead out of the site, and it&#8217;s quite easy to do when tracking statistics with Google Analytics. If you don&#8217;t already use Google Analytics with your MediaWiki site, open a new account in Google Analytics and see my previous post: <a href="/2007/07/13/track-mediawiki-statistics-using-google-analytics/">Track MediaWiki Statistics using Google Analytics</a>.</p>
<p><span id="more-7"></span>Now we two possible ways to add the tracking code to each external link. The first one is to hack the MediaWiki internal parser for wiki code to generate additional code for each link. While this way will probably work the best it&#8217;s pretty complicated and not straightforward. The other way, which is the one will follow, is to use a small JavaScript snippet which will will iterate through the links in every page and add an &#8220;onClick&#8221; attribute to them with the tracking code.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> links <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> links.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>links<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">className</span><span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;external text&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                addtrackcode<span style="color: #009900;">&#40;</span>links<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> addtrackcode<span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        obj.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onClick'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;javascript:urchinTracker('/outgoing/&quot;</span><span style="color: #339933;">+</span> obj.<span style="color: #660066;">href</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;://&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;');&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This code snippet should go between you Google Analytics code and the<code> &lt;/body&gt;</code> tag, meaning you can add it to <code>/wiki/skins/monobook.php</code> if you haven&#8217;t changed the default skin for your MediaWiki. After the code is in place it may take up to 48 hours (usually you don&#8217;t have to wait at all) for the external links statistics to show up in the Google Analytics. In the Google Analytics the statistics for clicking on an external link which leads to <a href="http://www.google.com">http://www.google.com</a> will show up as view of the page /outgoing/www.google.com. This script will also track download statistics of files which are linked from the wiki pages (like pdf&#8217;&#8217;s and such).</p>
<p>While this code does the job, it has a drawbacks. It only tracks the external links created by wiki code (e.g. <code>[http://example.com]</code>) as it uses CSS classes to determine what is external link. However this drawback isn&#8217;t very important and overall the script does a decent job tracking the external links in MediaWiki using Google Analytics.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Track MediaWiki Statistics using Google Analytics</title>
		<link>http://www.guyrutenberg.com/2007/07/13/track-mediawiki-statistics-using-google-analytics/</link>
		<comments>http://www.guyrutenberg.com/2007/07/13/track-mediawiki-statistics-using-google-analytics/#comments</comments>
		<pubDate>Fri, 13 Jul 2007 05:53:17 +0000</pubDate>
		<dc:creator>Guy</dc:creator>
				<category><![CDATA[Google Analytics]]></category>
		<category><![CDATA[MediaWiki]]></category>
		<category><![CDATA[Google]]></category>

		<guid isPermaLink="false">http://guy.sikumuna.com/2007/07/13/track-mediawiki-statistics-using-google-analytics/</guid>
		<description><![CDATA[Google Analytics is one of the best free web-statistics services available. It&#8217;s also quite easy to use with MediaWiki. To install Google Analytics in you MediaWiki you should put the tracking code, which is something that looks like:

&#60;script src=&#34;http://www.google-analytics.com/urchin.js&#34; type=&#34;text/javascript&#34;&#62;
&#60;/script&#62;
&#60;script type=&#34;text/javascript&#34;&#62;
_uacct=&#34;UA-xxxx-x&#34;;
urchinTracker&#40;&#41;;
&#60;/script&#62;

in every page, preferably just above the &#60;/body&#62; tag. The best way to do so [...]]]></description>
			<content:encoded><![CDATA[<p>Google Analytics is one of the best free web-statistics services available. It&#8217;s also quite easy to use with MediaWiki. To install Google Analytics in you MediaWiki you should put the tracking code, which is something that looks like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;script src=&quot;http://www.google-analytics.com/urchin.js&quot; type=&quot;text/javascript&quot;&gt;
&lt;/script&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
_uacct<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;UA-xxxx-x&quot;</span><span style="color: #339933;">;</span>
urchinTracker<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>in every page, preferably just above the &lt;/body&gt; tag. The best way to do so will be to put the tracking code inside the base skin php file. That means that unless you changed the default skin for MediaWiki you need to edit <code>/wiki/skins/MonoBook.php</code>. In this file you will find the &lt;/body&gt; tag towards the bottom of the file. Insert the tracking code just above it, save the file, and you&#8217;re done, as all pages will now show the script. Google Analytics will start gathering statistics usually in about 24-28 hours.</p>
<p>Update:<br />
If you also want to track external links to files and other websites take a look at<br />
<a href="/2007/07/16/tracking-mediawiki-external-links-statistics-using-google-analytics/">Tracking Mediawiki External Links Statistics Using Google Analytics</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.guyrutenberg.com/2007/07/13/track-mediawiki-statistics-using-google-analytics/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.426 seconds -->
