mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-29 22:45:14 -04:00
Fixes piwik-analytics extension.
This commit is contained in:
parent
9d8552a272
commit
1aec23008e
3 changed files with 36 additions and 41 deletions
|
@ -53,8 +53,7 @@ Run `makejs -t` to list all possible targets.
|
||||||
* localization now in separate files
|
* localization now in separate files
|
||||||
* updates translations
|
* updates translations
|
||||||
* adds `he` translation by [Tomer Cohen](https://github.com/tomer)
|
* adds `he` translation by [Tomer Cohen](https://github.com/tomer)
|
||||||
* updates [jQuery](http://jquery.com) to 1.8.0
|
* updates 3rd party libs
|
||||||
* updates [HTML5 ★ Boilerplate](http://html5boilerplate.com) to 4.0.0
|
|
||||||
|
|
||||||
|
|
||||||
### v0.21 - *2012-08-06*
|
### v0.21 - *2012-08-06*
|
||||||
|
|
|
@ -195,10 +195,11 @@ var H5AI_CONFIG = {
|
||||||
|
|
||||||
/* [all]
|
/* [all]
|
||||||
Adds Piwik tracker javascript code.
|
Adds Piwik tracker javascript code.
|
||||||
|
baseURL without protocol
|
||||||
*/
|
*/
|
||||||
"piwik-analytics": {
|
"piwik-analytics": {
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
"baseURL": "mydomain.tld/piwik", /* no protocol */
|
"baseURL": "mydomain.tld/piwik",
|
||||||
"idSite": 1
|
"idSite": 1
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,12 @@
|
||||||
|
|
||||||
modulejs.define('ext/piwik-analytics', ['_', 'core/settings'], function (_, allsettings) {
|
modulejs.define('ext/piwik-analytics', ['_', '$', 'core/settings'], function (_, $, allsettings) {
|
||||||
|
|
||||||
var defaults = {
|
var defaults = {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
"baseURL": "not-set",
|
baseURL: 'not-set',
|
||||||
"idSite": 0
|
idSite: 0
|
||||||
},
|
},
|
||||||
|
|
||||||
template = function(baseURL, idSite) {
|
|
||||||
|
|
||||||
return '<script type="text/javascript">
|
|
||||||
var pkBaseURL = (("https:" == document.location.protocol) ? "https://'+baseURL+'" : "http://'+baseURL+'");
|
|
||||||
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
|
|
||||||
</script><script type="text/javascript">
|
|
||||||
try {
|
|
||||||
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", '+idSite+');
|
|
||||||
piwikTracker.trackPageView();
|
|
||||||
piwikTracker.enableLinkTracking();
|
|
||||||
} catch( err ) {}
|
|
||||||
</script><noscript><p><img src="http://analytics.bluepyth.fr/piwik.php?idsite='+idSite+'" style="border:0" alt="" /></p></noscript>'
|
|
||||||
}
|
|
||||||
|
|
||||||
settings = _.extend({}, defaults, allsettings['piwik-analytics']),
|
settings = _.extend({}, defaults, allsettings['piwik-analytics']),
|
||||||
|
|
||||||
init = function () {
|
init = function () {
|
||||||
|
@ -29,9 +15,18 @@ modulejs.define('ext/piwik-analytics', ['_', 'core/settings'], function (_, alls
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $body = $('body');
|
// reference: http://piwik.org/docs/javascript-tracking/
|
||||||
|
|
||||||
$body.append(template(settings.baseURL, settings.idSite));
|
var pkBaseURL = (("https:" === document.location.protocol) ? "https://" : "http://") + settings.baseURL + '/';
|
||||||
|
|
||||||
|
$('<script/>').attr('src', pkBaseURL + 'piwik.js').appendTo('body');
|
||||||
|
$(window).load(function () {
|
||||||
|
/*global Piwik */
|
||||||
|
|
||||||
|
var piwikTracker = Piwik.getTracker(pkBaseURL + 'piwik.php', settings.idSite);
|
||||||
|
piwikTracker.trackPageView();
|
||||||
|
piwikTracker.enableLinkTracking();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue