GAnalytics dokuwiki plugin

By xantus on woensdag 20 januari 2010 09:53 - Comments (8)
Category: PHP, Views: 26.449

As a means to display Google Analytics we have created the ganalytics plugin. Also at the official dokuwiki plugin page: ganalytics

Download and Installation

Download and install the plugin using the Plugin Manager using the following URL. Refer to Plugins on how to install plugins manually.
  • 2009-05-04: Original version
Basic statistics can be displayed like this:
See available parameters for allowed options for <metrics>.
A number of parameters can be set by appending them with / character to data parameter. Each parameter needs to be separated with a / character. Defaults for all parameters can be set in the config manager. Below is a list of all recognized parameters and allowed values:
ParameterDefaultRequiredAllowed OptionsDescription
data:<metrics>-Yunique, pageviews, visitors,country, countrynewvisitors, browser, resolution, OS, referrers, searchwords, visitortypeMetrics which is displayed:
unique: Displays a line chart with the unique visitors on your on a day-by-day basis.
pageviews: Displays a line chart with the pageviews on your on a day-by-day basis.
visitors: Displays a line chart with the non-unique visitors on your on a day-by-day basis.
country: Displays a map chart with the location of your visitors for the selected range.
countrynewvisitors: Displays a map chart with the location of new visitors to your site for the selected range.
browser: Displays a pie chart with the browser used by your visitors for the selected range.
resolution: Displays a pie chart with the screen resolution used by your visitors for the selected range.
OS: Displays a pie chart with the operating system used by your visitors for the selected range.
referrers: Displays a pie chart with the referrers used by your visitors for the selected range.
searchwords: Displays a pie chart with the search engine keywords used by your visitors for the selected range.
visitortype: Displays a pie chart with vistor type for your visitors for the selected range (new visitor or returning visitor).
linecolor:<linecolor>000000N<hex color>[[, hex color], …]This parameter has different meanings for different charts:
Line chart: Color of the line, last value is repeated if there are more lines then colors
Pie chart: Color of the pie, colors are interpolated if there are more slices then colors
Map chart: Color of country's, first color is for country's which are not in the dataset, the other colors are interpolated
bgcolor:<bgcolor>FFFFFFN<hex color>Background color of the line and pie chart. Color of the water on map charts
size:<size>200×200N<integer>x<integer>Size of the chart. Best is to make the at least twice as wide as height.
history:<history>0N<integer>Selects how many previous months are included in the statistics. Example: setting it to 1 makes a pie chart display statistics of this month and the previous month
now:<now>-N<hex color>Shows a marker on line charts at the current date in color <now>
continent:<continent>worldNworld, africa, asia, europe, middle_east, south_america, usaSelects which area is displayed by the map chart
title:<title>-N<string>Displays title above chart (not allowed for map charts)

Additional setting
There are a few additional settings in the Configuration Manager:
Google Analytics usernameGoogle analytics username (email)
Google Analytics passwordGoogle analytics password
Google Analytics profile IDGoogle analytics profile ID (example ga:12345)
Show browser versionWhen selected, the data:browser option shows the browser version. Example Firefox or Firefox 3.
Show OS versionWhen selected, the data:osoption shows the OS version. Example Windows or Windows XP.
Maximum slices for pie chartThe maximum number of slices in a pie chart. The remaining slices are combine as '(other)'.
Show slice sizeWhen selected, a pie chart shows the size of each slice. Example Windows or Windows (80%)
Show referral pathWhen selected, the data:referrs shows the domain and referral path. Example or
3D pie chartWhen selected, pie charts are shown in 3D.
Use simple encoding (only for charts smaller then 300px)When selected, all data is encoded. This limits both URL size and resolution.
Adding metrics
Metrics are added in the following meaner:
  • Have a look at the Google Analytics Data Export API
  • Add a new function at the bottom of analytics.class.php
  • Add the new metric parameter in the handle-function. Adding it to the list of unique for a line chart, to country for a map chart or to browser for a pie chart.
  • Add the new metric parameter in the render-function. Same as above.
  • Add the new metric parameter in the PieChartGetData-function, MapChartGetData-function or LineChartGetData-function
  • Done :*)

Demo Installation

Unique visitors
{{ganalytics>data:unique/linecolor:007B9F,55A7BF,AAD3DF/size:550x220/history:2/now:FF0000/title:Unique visitors}},x,y&chco=007B9F,55A7BF,AAD3DF&chs=550x220&chtt=Unique%20visitors&chf=bg,s,FFFFFF&chd=s:Shu9kjjnYlg3grtedHAAAAAAAAAAAAA,tgrooiynx0qbZofqngbQYreZSTdfmuT,jrplorgbnvoqucfrwj7ibquyxptXXr&chxl=0:%7C1%7C2%7C3%7C4%7C5%7C6%7C7%7C8%7C9%7C10%7C11%7C12%7C13%7C14%7C15%7C16%7C17%7C18%7C19%7C20%7C21%7C22%7C23%7C24%7C25%7C26%7C27%7C28%7C29%7C30%7C31%7C1:%7CJanuary%7C2:%7C0%7C5%7C10%7C15%7C20%7C25%7C30%7C35%7C40%7C45%7C50%7C55%7C60%7C65%7C70&chdl=January%7CDecember%7CNovember&chg=16.67,14.29,1,5,13.33&chm=R,FF0000,0,0.579166666667,0.582166666667
Total visitors
{{ganalytics>data:visitors/linecolor:ED1C24,F68D91/size:550x220/history:1/now:0000FF/title:Total visitors}},x,y&chco=ED1C24,F68D91&chs=550x220&chtt=Total%20visitors&chf=bg,s,FFFFFF&chd=s:Sgq9noikbniufppgdHAAAAAAAAAAAAA,pdnkkgwrryngYkeiidbNWmZUQRcdjsW&chxl=0:%7C1%7C2%7C3%7C4%7C5%7C6%7C7%7C8%7C9%7C10%7C11%7C12%7C13%7C14%7C15%7C16%7C17%7C18%7C19%7C20%7C21%7C22%7C23%7C24%7C25%7C26%7C27%7C28%7C29%7C30%7C31%7C1:%7CJanuary%7C2:%7C0%7C5%7C10%7C15%7C20%7C25%7C30%7C35%7C40%7C45%7C50%7C55%7C60%7C65%7C70%7C75%7C80%7C85%7C90&chdl=January%7CDecember&chg=16.67,11.11,1,5,13.33&chm=R,0000FF,0,0.579166666667,0.582166666667
Total pageviews
Used browsers
Used screen resolution
{{ganalytics>data:resolution/size:550x220/linecolor:ED1C24/history:2/title:Screen resolution}},s,FFFFFF&chd=s:MMKJGECCCB&chl=1280x800%20(20.4%25)%7C1280x1024%20(19.3%25)%7C1024x768%20(17.2%25)%7C1680x1050%20(14.5%25)%7C1440x900%20(10.6%25)%7C1920x1200%20(6.2%25)%7C1920x1080%20(3.9%25)%7C1600x1200%20(3%25)%7C1366x768%20(2.6%25)%7C(Other)%20(2.3%25)
Used operating system
{{ganalytics>data:OS/size:550x220/linecolor:007B9F/history:2/title:Operating system}},s,FFFFFF&chd=s:iJFFDCBBBA&chl=Windows%20XP%20(56%25)%7CWindows%20Vista%20(14.9%25)%7CWindows%207%20(9%25)%7CLinux%20%20(8.4%25)%7CWindows%20NT%20(4.6%25)%7CMacintosh%20Intel%2010.6%20(3.4%25)%7CMacintosh%20Intel%2010.5%20(1.5%25)%7CWindows%20Server%202003%20(1%25)%7CWindows%202000%20(0.8%25)%7C(Other)%20(0.3%25)
Used keywords
Visitor type
{{ganalytics>data:visitortype/size:550x220/linecolor:22B14C,ED1C24/history:1/title:Visitor type}},ED1C24&chtt=Visitor%20type&chf=bg,s,FFFFFF&chd=s:xM&chl=New%20Visitor%20(79.8%25)%7CReturning%20Visitor%20(20.2%25)
Visitor location
Ask your questions at the official dokuwiki page.

Volgende: Stereo Vision Experiment 01-'10 Stereo Vision Experiment
Volgende: Blog statistieken 01-'10 Blog statistieken


By Tweakers user Phyxion, woensdag 20 januari 2010 10:27

Ziet er nice uit hoor :)

By Tweakers user bonus, woensdag 20 januari 2010 13:42

Title looks like something thats messed up completely but it correct indeed :)
Nice one !

By Tweakers user soczol, woensdag 20 januari 2010 14:33

Kleine vertaalfout: Google Analytics profiel ID > Google Analytics profile ID

By Tweakers user xantus, donderdag 21 januari 2010 15:33

Title looks like something thats messed up completely but it correct indeed :)
Nice one !
I got the same reaction from other dokuwiki users, when I posted the plugin at the official dokuwiki plugin page.
Kleine vertaalfout: Google Analytics profiel ID > Google Analytics profile ID
fixed :)

By Olivier, vrijdag 19 november 2010 11:33

I'm really interested in this plugin but the link doesn't seem to work anymore. Would there be an alternative place to download it ?

By tschinz, zaterdag 15 januari 2011 17:55

Where can the plugin be downloaded???? Please

By Cristiano Medeiros Dalbem, vrijdag 15 juni 2012 20:12

I would like to know where can I get this plugin. That's exactly what I was looking for, and I can't seem to find alternatives anywhere.

By Rizky, maandag 19 augustus 2013 12:46

Great post. I was checking coouunintsly this blog and I'm impressed! Very useful info specifically the last part I care for such information a lot. I was looking for this particular information for a very long time. Thank you and best of luck.

Comments are closed