mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-10-02 06:01:42 +00:00
Move Google Analytics integration into a proper plugin
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
title: $:/GoogleAnalyticsAccount
|
||||||
|
|
||||||
|
UA-32839735-1
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
title: $:/GoogleAnalyticsDomain
|
||||||
|
|
||||||
|
tiddlywiki.com
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
title: $:/wiki/analytics
|
|
||||||
type: application/javascript
|
|
||||||
library: yes
|
|
||||||
|
|
||||||
var _gaq = _gaq || [];
|
|
||||||
_gaq.push(['_setAccount', 'UA-32839735-1']);
|
|
||||||
_gaq.push(['_setDomainName', 'tiddlywiki.com']);
|
|
||||||
_gaq.push(['_trackPageview']);
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
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';
|
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|
||||||
})();
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"tiddlywiki/fullscreen",
|
"tiddlywiki/fullscreen",
|
||||||
|
"tiddlywiki/googleanalytics",
|
||||||
"tiddlywiki/github-fork-ribbon"
|
"tiddlywiki/github-fork-ribbon"
|
||||||
],
|
],
|
||||||
"themes": [
|
"themes": [
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/*\
|
||||||
|
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";
|
||||||
|
|
||||||
|
var GOOGLE_ANALYTICS_ACCOUNT = "$:/GoogleAnalyticsAccount",
|
||||||
|
GOOGLE_ANALYTICS_DOMAIN = "$:/GoogleAnalyticsDomain";
|
||||||
|
|
||||||
|
exports.startup = function() {
|
||||||
|
if($tw.browser) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"title": "$:/plugins/tiddlywiki/googleanalytics",
|
||||||
|
"description": "Google Analytics plugin for TiddlyWiki5",
|
||||||
|
"author": "JeremyRuston",
|
||||||
|
"core-version": ">=5.0.0"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user