Integrating Statcounter-javascript code into each Tiddler doesn't work (via macro-call)

48 views
Skip to first unread message

Gesundelehre

unread,
Feb 9, 2017, 9:34:44 AM2/9/17
to TiddlyWiki
Hi there,

I try to implement a hitcounter (with the statcounter-code) into every single Tiddler.
So far i understood that in TW5 it's not possible anymore to directly implement javascript code into a tiddler because of the security risk.

Thus i tried to make a macro that can be called via <<statcounter>>
However, it doesn't work.

Can anyone help me and tell me why it doesn't work?

This is how it presently looks like:


--------------
Tiddler-Title: statcounter.js
--------------
Tiddler-Content:

(function(){

"use strict";
exports.name = "statcounter";
exports.params = [];

/*
Run the macro
*/
exports.run = function(format) {
var sc_project=SOMENUMBER;
var sc_invisible=1;
var sc_security="SOMEALPHANUMERICALCODE";
var scJsHost = (("https:" == document.location.protocol) ? "https://secure." : "http://www.");
document.write("<sc"+"ript type='text/javascript' src='" + scJsHost+ "statcounter.com/counter/counter.js'></"+"script>");
};

})();

--------------
field "module-type": macro
type: application/javascript
--------------

In another tiddler i tried to call the macro via <<statcounter>> and it doesn't work

Maybe I have to add, that the TW5 is located on my harddrive and i call it locally through file:///C:/PathToTiddlywiki/tiddlywiki.html

PMario

unread,
Feb 9, 2017, 10:20:51 AM2/9/17
to TiddlyWiki
Hi,

Requests like this should definitely go to the dev group: https://groups.google.com/forum/#!forum/tiddlywikidev

... Where did you get the code from? I can't find any API definitions at the statcounter .com site. You may consider to use open source software instead of proprietary tracking black boxes.

-m

Danielo Rodríguez

unread,
Feb 9, 2017, 1:25:56 PM2/9/17
to TiddlyWiki
Why do you think that it does not work ? What is the expected output and what is the actual one ?

In any case, list of tw's JavaScript code runs inside a sandbox , so maybe document is not what you think . Just try with window.document instead

Reply all
Reply to author
Forward
0 new messages