mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-25 12:34:47 -04:00
Adds Google Analytics support (async).
This commit is contained in:
parent
65b1823c5d
commit
e25e5b72f4
3 changed files with 49 additions and 0 deletions
|
@ -115,6 +115,24 @@ var H5AI_CONFIG = {
|
||||||
"folders": {}
|
"folders": {}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Adds Google Analytics asynchronous tracking code.
|
||||||
|
*
|
||||||
|
* for example:
|
||||||
|
* "gaq": [
|
||||||
|
* ["_setAccount", "UA-xxxxxx-x"],
|
||||||
|
* ["_setDomainName", ".your-domain.tld"],
|
||||||
|
* ["_trackPageview"],
|
||||||
|
* ["_trackPageLoadTime"]
|
||||||
|
* ]
|
||||||
|
*
|
||||||
|
* see: http://support.google.com/googleanalytics/bin/topic.py?hl=en&topic=27612
|
||||||
|
*/
|
||||||
|
"google-analytics": {
|
||||||
|
"enabled": false,
|
||||||
|
"gaq": []
|
||||||
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Localization, for example "en", "de" etc. - see "langs" below for
|
* Localization, for example "en", "de" etc. - see "langs" below for
|
||||||
* possible values. Adjust it to your needs. If lang is not found in
|
* possible values. Adjust it to your needs. If lang is not found in
|
||||||
|
|
30
src/_h5ai/js/inc/ext/google-analytics.js
Normal file
30
src/_h5ai/js/inc/ext/google-analytics.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
modulejs.define('ext/google-analytics', ['_', 'core/settings'], function (_, allsettings) {
|
||||||
|
|
||||||
|
var defaults = {
|
||||||
|
enabled: false,
|
||||||
|
gaq: []
|
||||||
|
},
|
||||||
|
|
||||||
|
settings = _.extend({}, defaults, allsettings['google-analytics']),
|
||||||
|
|
||||||
|
init = function () {
|
||||||
|
|
||||||
|
if (!settings.enabled) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window._gaq = settings.gaq;
|
||||||
|
|
||||||
|
var strScript = 'script',
|
||||||
|
doc = document,
|
||||||
|
newScriptTag = doc.createElement(strScript),
|
||||||
|
firstScriptTag = doc.getElementsByTagName(strScript)[0];
|
||||||
|
|
||||||
|
newScriptTag.async = true;
|
||||||
|
newScriptTag.src = ('https:' === location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
|
firstScriptTag.parentNode.insertBefore(newScriptTag, firstScriptTag);
|
||||||
|
};
|
||||||
|
|
||||||
|
init();
|
||||||
|
});
|
|
@ -28,6 +28,7 @@
|
||||||
// @include "ext/download.js"
|
// @include "ext/download.js"
|
||||||
// @include "ext/filter.js"
|
// @include "ext/filter.js"
|
||||||
// @include "ext/folderstatus.js"
|
// @include "ext/folderstatus.js"
|
||||||
|
// @include "ext/google-analytics.js"
|
||||||
// @include "ext/l10n.js"
|
// @include "ext/l10n.js"
|
||||||
// @include "ext/link-hover-states.js"
|
// @include "ext/link-hover-states.js"
|
||||||
// @include "ext/mode.js"
|
// @include "ext/mode.js"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue