diff --git a/licenses/cla-individual.md b/licenses/cla-individual.md index 6c497c14f..43df0e5d1 100644 --- a/licenses/cla-individual.md +++ b/licenses/cla-individual.md @@ -300,3 +300,5 @@ Hans Christian Haase, @hchaase, 2016/08/11 steve schneider, @stevesunypoly, 2016/08/26 Nuno Mota, @nmota, 2016/12/16 + +Sylvain Comte, @sycom, 2016/12/20 diff --git a/plugins/tiddlywiki/googleanalytics/googleanalytics.js b/plugins/tiddlywiki/googleanalytics/googleanalytics.js index 974a1c253..e592c124c 100644 --- a/plugins/tiddlywiki/googleanalytics/googleanalytics.js +++ b/plugins/tiddlywiki/googleanalytics/googleanalytics.js @@ -17,19 +17,20 @@ exports.name = "google-analytics"; exports.platforms = ["browser"]; exports.synchronous = true; -var GOOGLE_ANALYTICS_ACCOUNT = "$:/GoogleAnalyticsAccount", - GOOGLE_ANALYTICS_DOMAIN = "$:/GoogleAnalyticsDomain"; - exports.startup = function() { - window._gaq = window._gaq || []; - _gaq.push(["_setAccount", $tw.wiki.getTiddlerText(GOOGLE_ANALYTICS_ACCOUNT)]); - _gaq.push(["_setDomainName", $tw.wiki.getTiddlerText(GOOGLE_ANALYTICS_DOMAIN)]); - _gaq.push(["_trackPageview"]); - var ga = document.createElement("script"); - ga.type = "text/javascript"; - ga.async = true; - ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js"; - document.body.appendChild(ga); + // getting parameters + var GA_ACCOUNT = $tw.wiki.getTiddlerText("$:/GoogleAnalyticsAccount").replace(/\n/g,""), + GA_DOMAIN = $tw.wiki.getTiddlerText("$:/GoogleAnalyticsDomain").replace(/\n/g,""); + if (GA_DOMAIN == "" || GA_DOMAIN == undefined) GA_DOMAIN = "auto"; + + // using ga "isogram" function + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); + + ga('create', GA_ACCOUNT, GA_DOMAIN); + ga('send', 'pageview'); }; })(); diff --git a/plugins/tiddlywiki/googleanalytics/plugin.info b/plugins/tiddlywiki/googleanalytics/plugin.info index 6fd93b295..d7864b65e 100644 --- a/plugins/tiddlywiki/googleanalytics/plugin.info +++ b/plugins/tiddlywiki/googleanalytics/plugin.info @@ -2,6 +2,8 @@ "title": "$:/plugins/tiddlywiki/googleanalytics", "description": "Google Analytics: website statistics", "author": "JeremyRuston", + "contributor": "Sylvain Comte", + "version":"5.1.14", "core-version": ">=5.0.0", - "list": "readme usage" + "list": "readme settings usage" } diff --git a/plugins/tiddlywiki/googleanalytics/readme.tid b/plugins/tiddlywiki/googleanalytics/readme.tid index 616b7bc64..8a94012eb 100644 --- a/plugins/tiddlywiki/googleanalytics/readme.tid +++ b/plugins/tiddlywiki/googleanalytics/readme.tid @@ -1,5 +1,5 @@ title: $:/plugins/tiddlywiki/googleanalytics/readme -This plugin enables you to use Google Analytics to track access to your online TiddlyWiki document. +This plugin enables you to use Google Analytics to track access to your online TiddlyWiki document. Based upon the [[official Google code|https://developers.google.com/analytics/devguides/collection/analyticsjs]]. [[Source code|https://github.com/Jermolene/TiddlyWiki5/blob/master/plugins/tiddlywiki/googleanalytics]] diff --git a/plugins/tiddlywiki/googleanalytics/settings.tid b/plugins/tiddlywiki/googleanalytics/settings.tid new file mode 100644 index 000000000..986d65644 --- /dev/null +++ b/plugins/tiddlywiki/googleanalytics/settings.tid @@ -0,0 +1,7 @@ +title: $:/plugins/tiddlywiki/googleanalytics/settings + +You have only two value to set, only first is mandatory : + +# ''[[Google Analytics Account|$:/GoogleAnalyticsAccount]]'', usually a `UA-XXXXXX-XX` code where X are digits (yours is best ;-). ''This one is mandatory'', plugin will not work without it...
<$edit-text tiddler="$:/GoogleAnalyticsAccount" default="" tag="input"/> + +# ''[[Google Analytics Domain|$:/GoogleAnalyticsDomain]]''. Usually the website URL where your tiddlywiki is published. will fallback to `auto` if not set.
<$edit-text tiddler="$:/GoogleAnalyticsDomain" default="" tag="input"/> diff --git a/plugins/tiddlywiki/googleanalytics/usage.tid b/plugins/tiddlywiki/googleanalytics/usage.tid index a59684424..4bbaac073 100644 --- a/plugins/tiddlywiki/googleanalytics/usage.tid +++ b/plugins/tiddlywiki/googleanalytics/usage.tid @@ -1,16 +1,23 @@ title: $:/plugins/tiddlywiki/googleanalytics/usage -These instructions assume you are using TiddlySpot to publish your wiki. +!! Create a google analytics account +If you already got one, go to next step, else # Go to the Google Analytics website: http://www.google.com/analytics/ # Click the ''Access Google Analytics'' button and follow instructions to set up your account -# Enter the name of your TiddlySpot domain, for example "mysite.tiddlyspot.com" -# You will be given your own Tracking ID for this domain -# Go to http://tiddlywiki.com -- open the More/System tab and drag the links to these three tiddlers across to a local copy of your site: -#* [[$:/GoogleAnalyticsDomain]] -#* [[$:/GoogleAnalyticsAccount]] -#* [[$:/plugins/tiddlywiki/googleanalytics]] -# Edit the first two of these tiddlers to reflect your Domain and Tracking ID -# Upload the new version to TiddlySpot or other web host -# Return to your Google Analytics page to check that your site is being tracked +# Enter the URL of your hosting domain, might be a TiddlySpot one for example "mysite.tiddlyspot.com" or even a github.io or gitlab.io url +# You will be given your own Tracking ID for this domain `UA-XXXXXX-XX` +!! Install the plugin on your local copy of the tiddlywiki + +# ''BACKUP your tiddlywiki''. Just in case. +# grab a copy of the plugin [[$:/plugins/tiddlywiki/googleanalytics]] from a wiki containing it like http://tiddlywiki.com to yours +# save the tiddlywiki, refresh the page to load the plugin +# in your tiddlywiki, go to [[$:/ControlPanel]] > Plugins tab. Unfold the Google Analytics box. +# go to //settings// tabs and edit parameters : Google Analytics Account and Google Analytics Domain +# save the tiddlywiki + +!! Upload the new version of your tiddlywiki + +# Upload the saved tiddlywiki to TiddlySpot, github, gitlab or other web host +# Return to your Google Analytics page to check that your site is being tracked