1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-02 10:13:16 +00:00
TiddlyWiki5/plugins/tiddlywiki/googleanalytics/googleanalytics.js
Sylvain Comte c16f96626e 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
2017-01-03 15:43:05 +00:00

37 lines
1.2 KiB
JavaScript

/*\
title: $:/plugins/tiddlywiki/googleanalytics/googleanalytics.js
type: application/javascript
module-type: startup
Runs Google Analytics with the account number in the tiddler `$:/GoogleAnalyticsAccount` and the domain name in `$:/GoogleAnalyticsDomain`
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
// Export name and synchronous status
exports.name = "google-analytics";
exports.platforms = ["browser"];
exports.synchronous = true;
exports.startup = function() {
// 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');
};
})();