From 5b5621a600a8a774c6ce10c960424c89ba287d43 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Sat, 3 May 2014 18:07:20 +0100 Subject: [PATCH] Fix googleanalytics plugin to be platform-specific --- .../googleanalytics/googleanalytics.js | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/tiddlywiki/googleanalytics/googleanalytics.js b/plugins/tiddlywiki/googleanalytics/googleanalytics.js index a69a912d0..974a1c253 100644 --- a/plugins/tiddlywiki/googleanalytics/googleanalytics.js +++ b/plugins/tiddlywiki/googleanalytics/googleanalytics.js @@ -14,23 +14,22 @@ Runs Google Analytics with the account number in the tiddler `$:/GoogleAnalytics // Export name and synchronous status exports.name = "google-analytics"; +exports.platforms = ["browser"]; exports.synchronous = true; 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); - } + 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); }; })();