GAnalytics dokuwiki plugin

By xantus on Wednesday 20 January 2010 09:53 - Comments (8)
Category: PHP, Views: 19.128

As a means to display Google Analytics we have created the ganalytics plugin.

http://u1.ipernity.com/14/28/39/7172839.5ef323dd.png 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.
Changes
  • 2009-05-04: Original version
Syntax
Basic statistics can be displayed like this:
{{ganalytics>data:<metrics>}}
See available parameters for allowed options for <metrics>.
Parameters
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>200200N<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)

example
{{ganalytics>data:<metrics>[/linecolor:<linecolor>][/bgcolor:<bgcolor>][/size:<size>][/history:<history>][/now:<now>][/continent:<continent>][/title:<title>]}}
{{ganalytics>data:unique/linecolor:007B9F,55A7BF,AAD3DF/size:550x220/history:2/now:FF0000}}
{{ganalytics>data:countrynewvisitors/continent:world/size:440x220/linecolor:FFFFFF,FFFFFF,019E18/bgcolor:EAF7FE/history:5}}
Additional setting
There are a few additional settings in the Configuration Manager:
SettingDescription
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 example.com or example.com/dir/.
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}}

[img]http://chart.apis.google.com/chart?cht=lc&chxt=x,x,y&chco=007B9F,55A7BF,AAD3DF&chs=550x220&chtt=Unique%20visitors&chf=bg,s,FFFFFF&chd=s:Shu9kjjnYlg3grtedHAAAAAAAAAAAAA,tgrooiynx0qbZofqngbQYreZSTdfmuT,jrplorgbnvoqucfrwj7ibquyxptXXr&chxl=0:|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|1:|January|2:|0|5|10|15|20|25|30|35|40|45|50|55|60|65|70&chdl=January|December|November&chg=16.67,14.29,1,5,13.33&chm=R,FF0000,0,0.579166666667,0.582166666667[/img]
Total visitors
{{ganalytics>data:visitors/linecolor:ED1C24,F68D91/size:550x220/history:1/now:0000FF/title:Total visitors}}

[img]http://chart.apis.google.com/chart?cht=lc&chxt=x,x,y&chco=ED1C24,F68D91&chs=550x220&chtt=Total%20visitors&chf=bg,s,FFFFFF&chd=s:Sgq9noikbniufppgdHAAAAAAAAAAAAA,pdnkkgwrryngYkeiidbNWmZUQRcdjsW&chxl=0:|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|1:|January|2:|0|5|10|15|20|25|30|35|40|45|50|55|60|65|70|75|80|85|90&chdl=January|December&chg=16.67,11.11,1,5,13.33&chm=R,0000FF,0,0.579166666667,0.582166666667[/img]
Total pageviews
{{ganalytics>data:pageviews/linecolor:FFC004,FFD558,FFEAAC/size:550x220/history:2/now:FF0000/title:Pageviews}}

[img]http://chart.apis.google.com/chart?cht=lc&chxt=x,x,y&chco=FFC004,FFD558,FFEAAC&chs=550x220&chtt=Pageviews&chf=bg,s,FFFFFF&chd=s:IdWjYaRXXZShcXTZOGAAAAAAAAAAAAA,bcVZXZslacVaNUSUURPGMSQMLLhTUkS,dabSSdPebWWUhOSjiSbNTXZYdSkON9&chxl=0:|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|1:|January|2:|0|50|100|150|200|250|300|350|400&chdl=January|December|November&chg=16.67,25,1,5,13.33&chm=R,FF0000,0,0.579166666667,0.582166666667[/img]
Used browsers
{{ganalytics>data:browser/size:550x220/linecolor:22B14C/history:2/title:Browsers}}

[img]http://chart.apis.google.com/chart?cht=p&chs=550x220&chco=22B14C&chtt=Browsers&chf=bg,s,FFFFFF&chd=s:gKFEDDBBBB&chl=Firefox%20Version3%20(52.8%)|Internet%20Explorer%20Version8%20(16.2%)|Internet%20Explorer%20Version7%20(7.5%)|Opera%20Version9%20(7%)|Chrome%20Version3%20(5.3%)|Internet%20Explorer%20Version6%20(4.7%)|Safari%20Version531%20(2.4%)|Chrome%20Version4%20(2.1%)|Mozilla%20Version1%20(1.1%)|(Other)%20(1%)[/img]
Used screen resolution
{{ganalytics>data:resolution/size:550x220/linecolor:ED1C24/history:2/title:Screen resolution}}

[img]http://chart.apis.google.com/chart?cht=p&chs=550x220&chco=ED1C24&chtt=Screen%20resolution&chf=bg,s,FFFFFF&chd=s:MMKJGECCCB&chl=1280x800%20(20.4%)|1280x1024%20(19.3%)|1024x768%20(17.2%)|1680x1050%20(14.5%)|1440x900%20(10.6%)|1920x1200%20(6.2%)|1920x1080%20(3.9%)|1600x1200%20(3%)|1366x768%20(2.6%)|(Other)%20(2.3%)[/img]
Used operating system
{{ganalytics>data:OS/size:550x220/linecolor:007B9F/history:2/title:Operating system}}

[img]http://chart.apis.google.com/chart?cht=p&chs=550x220&chco=007B9F&chtt=Operating%20system&chf=bg,s,FFFFFF&chd=s:iJFFDCBBBA&chl=Windows%20XP%20(56%)|Windows%20Vista%20(14.9%)|Windows%207%20(9%)|Linux%20%20(8.4%)|Windows%20NT%20(4.6%)|Macintosh%20Intel%2010.6%20(3.4%)|Macintosh%20Intel%2010.5%20(1.5%)|Windows%20Server%202003%20(1%)|Windows%202000%20(0.8%)|(Other)%20(0.3%)[/img]
Used keywords
{{ganalytics>data:searchwords/size:550x220/linecolor:22B14C/history:2/title:Searchwords}}

[img]http://chart.apis.google.com/chart?cht=p&chs=550x220&chco=22B14C&chtt=Searchwords&chf=bg,s,FFFFFF&chd=s:nEEDCCCCCC&chl=kb927917%20(63.3%)|vga%20protocol%20(6.9%)|dokuwiki%20menu%20(6.9%)|dokuwiki%20icons%20(4.9%)|fpga%20psp%20lcd%20(3.7%)|nixie%20thermometer%20(3.7%)|reflow%20toaster%20(2.9%)|(Other)%20(2.6%)|crt%20clock%20(2.6%)|creating%20delays%20in%20avr%2016%20(2.6%)[/img]
Referrers
{{ganalytics>data:referrers/size:550x220/linecolor:ED1C24/history:1//title:Referrers}}

[img]http://chart.apis.google.com/chart?cht=p&chs=550x220&chco=ED1C24&chtt=Referrers&chf=bg,s,FFFFFF&chd=s:SNMGDCCCCB&chl=google%20(29.3%)|hotscripts.com%20(21.8%)|(direct)%20(19.3%)|dokuwiki.org%20(10%)|youtube.com%20(5.2%)|script.wareseeker.com%20(3.7%)|circuitsonline.net%20(3.4%)|bing%20(3.2%)|yahoo%20(2.7%)|(Other)%20(1.5%)[/img]
Visitor type
{{ganalytics>data:visitortype/size:550x220/linecolor:22B14C,ED1C24/history:1/title:Visitor type}}

[img]http://chart.apis.google.com/chart?cht=p&chs=550x220&chco=22B14C,ED1C24&chtt=Visitor%20type&chf=bg,s,FFFFFF&chd=s:xM&chl=New%20Visitor%20(79.8%)|Returning%20Visitor%20(20.2%)[/img]
Visitor location
{{ganalytics>data:country/continent:world/size:440x220/linecolor:FFFFFF,FFFFFF,019E18/bgcolor:EAF7FE/history:5}}

http://chart.apis.google.com/chart?cht=t&chtm=world&chs=440x220&chco=FFFFFF,FFFFFF,019E18&chf=bg,s,EAF7FE&chld=YTMZMQLYRWSRAOSDSNSMLBLIKHJEBWBTBSSVFOJMIMGTGUPYMEQAMUTNTJCMAZCRBODOECANUGMNPATTALMDBHDZCUJOMAPRMTISUZLKAMNPUYNGCYLUKWPEGEKZSAVEEEAELVCLBYBDCOEGIESIBANZILPKTWRSHKVNSGLTMYPHHRSKIRZAPTTHNODKMXJPATUAGRBGKRSEIDTRCHFIARBRESAURORUCZHUITCABECNINFRGBPLDENLUS&chd=s:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCDDDDDDDDDDEEEFFFFFGGGHHIIIJKMOPPVYby9
Discussion
Ask your questions at the official dokuwiki page.
http://www.greenbird.info/img.php?h&b=ganalytics-dokuwiki-plugin&f

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

Comments


By Tweakers user Phyxion, Wednesday 20 January 2010 10:27

Ziet er nice uit hoor :)

By Tweakers user bonus, Wednesday 20 January 2010 13:42

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

By Tweakers user soczol, Wednesday 20 January 2010 14:33

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

By Tweakers user xantus, Thursday 21 January 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, Friday 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, Saturday 15 January 2011 17:55

Where can the plugin be downloaded???? Please

By Cristiano Medeiros Dalbem, Friday 15 June 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, Monday 19 August 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