Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Google Analytics in the admin area?
The Google Analytics API has been around for a while, but might the recently announced Easy Dashboard Library be an easier way of perhaps creating a general and/or tailored Google Analytics admin tab?
Probably plugin territory, but possibly easier to put into practice now than before?
TXP Builders – finely-crafted code, design and txp
Offline
Re: Google Analytics in the admin area?
+1 :)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: Google Analytics in the admin area?
+1 bounty anyone?
Offline
Re: Google Analytics in the admin area?
The Piwik way is super easy to use with smd_xml and then something like smd_tabber. Example:
<p><strong>Top keywords in the last month</strong>:</p>
<txp:smd_xml wraptag="p" data="http://example.com/piwik/?module=API&method=Referers.getKeywords&idSite=1&date=yesterday&period=month&format=xml&filter_limit=10&token_auth=PASTE_YOUR_AUTH_KEY_HERE" record="row" fields="label, nb_visits">
{label} ({nb_visits} visits)<br />
</txp:smd_xml>
Would yield this:
Top keywords in the last month:
Textpattern tutorials (78 visits)
Textpattern themes (56 visits)
So if you use Google Analytics’ XML via their API, this would work too.
The API reference would tell you which fields are available for use. And of course you can do mathematical operations on them, encourage your clients to do better next time, etc. :-)
Last edited by maruchan (2012-06-06 18:59:16)
Offline
Re: Google Analytics in the admin area?
Oh, and this dashboard library looks pretty simple to use, too. I don’t think you’d need a plugin for it.
Offline
Re: Google Analytics in the admin area?
Hi Marc, you might well be right with smd_tabber.
I’ve not looked at the easy dashboard library in enough detail or tried it out, just read what arrived in one of their mails and thought it looked a bit more straightforward. Perhaps it’s just a matter of a couple of txp-users compiling a library of common stats views in a txptip or a series of txptips.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Google Analytics in the admin area?
I’ve been meaning to look at this but haven’t had time. I did throw together a plugin to show some piwik data last year.
The issue with a Google Analytics Pluign is every site needs their own API Access key since the javascript calls must come from the domain in the JavaScript origins field… but…
Using the Cool Demo I threw together a page template that can be used to create a tab with smd_tabber.
GoogleAnalyticsSampleDashboard.txt (Use smd_tabber or some other tab creating plugin and this template to create a Google Analytics Dashboard in the Textpattern Admin.) At some point I forgot about this and deleted the file.
Edit:looks Ike it may need some more work on the auth front. Not working for me in a new browser.
Last edited by MattD (2014-11-24 23:57:34)
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: Google Analytics in the admin area?
Perhaps I’ll get time to put a txptip together soon.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: Google Analytics in the admin area?
Here’s a fun one if you have Piwik installed:
The code uses the smd_xml plugin. Then we use the Piwik API’s “UseCountry.getCountry” method to grab some information:
<h1>People come here from all over.</h1>
<p>In the last year, visitors from the following countries have enjoyed my website:</p>
<txp:smd_xml wraptag="p" data="http://example.com/piwik/?module=API&method=UserCountry.getCountry&idSite=1&date=yesterday&period=year&format=xml&filter_limit=60&token_auth=YOUR_TOKEN_AUTH_HERE" record="row" fields="label, logo">
<txp:variable name="origin">{label}</txp:variable>
<txp:if_variable name="origin" value="Unknown">
<txp:else />
<img src="http://www.example.com/piwik/{logo}" title="{label}" />
{label}
</txp:if_variable>
</txp:smd_xml>
<p>I hope you enjoy your visit, too. :-)</p>
The options are all in the URL you put in smd_xml’s “data” field:
http://www.example.com/piwik
is the location of your Piwik install. Make sure to update this below, too, where the flag image is referred to. Piwik comes with flag images built-in.
idSite=1
is the ID number of the website inside Piwik. If you have multiple sites, this might be some other number.
date=yesterday
tells Piwik to count starting yesterday.
period=year
tells Piwik you want information from the last year.
format=xml
tells Piwik to give you the information in XML format. This is important because we are using smd_xml to display the data.
filter_limit=60
tells Piwik you want a maximum of 60 items. I have used this only as an example.
token_auth
is *very important*— you must use your Piwik control panel to get your authorization code. Otherwise this data won’t be available to you when you use the URL.
Then we have this:
<txp:variable name="origin">{label}</txp:variable>
<txp:if_variable name="origin" value="Unknown">
<txp:else />
<img src="http://www.example.com/piwik/{logo}" title="{label}" />
{label}
</txp:if_variable>
Piwik will include an ugly gray flag with a “?” question mark on it, representing countries it cannot track. We are using if_variable
to test if this is the case. If so, we do nothing. If not, we display the flag and the country name.
Don’t forget to replace “example.com” with your actual URL.
Offline
Re: Google Analytics in the admin area?
There’s a new embedded analytics API I was looking at throwing some of their examples into a plugin but ran into issues with authenticating.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: Google Analytics in the admin area?
I got something working using the embedded api. Feel free to check it out by downloading the plugin.
Comments and issues can be reported in the forum post
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline