2013-11-25 23:14:12 +00:00
|
|
|
/*\
|
|
|
|
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";
|
|
|
|
|
2014-05-03 15:32:18 +00:00
|
|
|
// Export name and synchronous status
|
|
|
|
exports.name = "google-analytics";
|
2014-05-03 17:07:20 +00:00
|
|
|
exports.platforms = ["browser"];
|
2014-05-03 15:32:18 +00:00
|
|
|
exports.synchronous = true;
|
|
|
|
|
2013-11-25 23:14:12 +00:00
|
|
|
var GOOGLE_ANALYTICS_ACCOUNT = "$:/GoogleAnalyticsAccount",
|
|
|
|
GOOGLE_ANALYTICS_DOMAIN = "$:/GoogleAnalyticsDomain";
|
|
|
|
|
|
|
|
exports.startup = function() {
|
2014-05-03 17:07:20 +00:00
|
|
|
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);
|
2013-11-25 23:14:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
})();
|