mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-11 18:00:26 +00:00
Fix googleanalytics plugin to be platform-specific
This commit is contained in:
parent
78ba57d55d
commit
5b5621a600
@ -14,23 +14,22 @@ Runs Google Analytics with the account number in the tiddler `$:/GoogleAnalytics
|
|||||||
|
|
||||||
// Export name and synchronous status
|
// Export name and synchronous status
|
||||||
exports.name = "google-analytics";
|
exports.name = "google-analytics";
|
||||||
|
exports.platforms = ["browser"];
|
||||||
exports.synchronous = true;
|
exports.synchronous = true;
|
||||||
|
|
||||||
var GOOGLE_ANALYTICS_ACCOUNT = "$:/GoogleAnalyticsAccount",
|
var GOOGLE_ANALYTICS_ACCOUNT = "$:/GoogleAnalyticsAccount",
|
||||||
GOOGLE_ANALYTICS_DOMAIN = "$:/GoogleAnalyticsDomain";
|
GOOGLE_ANALYTICS_DOMAIN = "$:/GoogleAnalyticsDomain";
|
||||||
|
|
||||||
exports.startup = function() {
|
exports.startup = function() {
|
||||||
if($tw.browser) {
|
window._gaq = window._gaq || [];
|
||||||
window._gaq = window._gaq || [];
|
_gaq.push(["_setAccount", $tw.wiki.getTiddlerText(GOOGLE_ANALYTICS_ACCOUNT)]);
|
||||||
_gaq.push(["_setAccount", $tw.wiki.getTiddlerText(GOOGLE_ANALYTICS_ACCOUNT)]);
|
_gaq.push(["_setDomainName", $tw.wiki.getTiddlerText(GOOGLE_ANALYTICS_DOMAIN)]);
|
||||||
_gaq.push(["_setDomainName", $tw.wiki.getTiddlerText(GOOGLE_ANALYTICS_DOMAIN)]);
|
_gaq.push(["_trackPageview"]);
|
||||||
_gaq.push(["_trackPageview"]);
|
var ga = document.createElement("script");
|
||||||
var ga = document.createElement("script");
|
ga.type = "text/javascript";
|
||||||
ga.type = "text/javascript";
|
ga.async = true;
|
||||||
ga.async = true;
|
ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
|
||||||
ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
|
document.body.appendChild(ga);
|
||||||
document.body.appendChild(ga);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user