mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 18:17:20 +00:00
Update to latest version of google analytics code (#2671)
* trying to implement new googleanalytics tracker * trying to put new google tracker. Not working... * more dev options for testing still don"t understand wants goes wrong * New version. Seems to work * achieved update for new tests brought back tiddlywiki.com settings value created a settings tab to make it easier * adding settings to plugin add a settings tab to plugin to make it easier to use and see which GA account is in use * fixes bug with GA_ACCOUNT and GA_DOMAIN tiddlers containing newlines at their end, preventing plugins to work * soft rebase on jermolene's master * revert to oldest version of GA_account and GA_domain tiddlers - had been overwritten by ones with a new line at the end * Integrates some @tobibeer comments * googleanalytics.js : removed "rebranding", var declaration and console log. Did not manage to get a non-minified version of Google script. But as far as I can see, jermolene's original plugin did same way * plugin.info : placed "readme" first * readme : back to previous "legacy" version. No more mention to temporary fork. Added mention and link to google official code. * signed CLA
This commit is contained in:
parent
56131e4563
commit
c16f96626e
@ -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
|
||||
|
@ -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');
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -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"
|
||||
}
|
||||
|
@ -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]]
|
||||
|
7
plugins/tiddlywiki/googleanalytics/settings.tid
Normal file
7
plugins/tiddlywiki/googleanalytics/settings.tid
Normal file
@ -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...<br/><$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.<br/><$edit-text tiddler="$:/GoogleAnalyticsDomain" default="" tag="input"/>
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user