2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-06-23 15:16:32 +09:00
|
|
|
import Events from '../collection.js';
|
|
|
|
|
2016-06-05 11:33:25 +09:00
|
|
|
Events.analyticsRequest = function() {
|
|
|
|
// Google Analytics
|
|
|
|
if (typeof window.ga !== 'undefined'){
|
|
|
|
window.ga('send', 'pageview', {
|
2016-06-14 10:01:44 +09:00
|
|
|
'page': window.location.pathname
|
2016-06-05 11:33:25 +09:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-10-20 11:55:22 +09:00
|
|
|
Events.analyticsInit = function() {
|
2013-10-30 08:27:44 +09:00
|
|
|
|
2013-02-28 09:19:08 +09:00
|
|
|
// Google Analytics
|
2016-11-15 09:02:30 +01:00
|
|
|
const googleAnalyticsId = Telescope.settings.get("googleAnalyticsId");
|
|
|
|
if (googleAnalyticsId) {
|
2013-10-30 08:27:44 +09:00
|
|
|
|
2013-10-31 09:55:44 +09:00
|
|
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
|
|
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
|
|
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
|
|
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
2013-02-28 09:19:08 +09:00
|
|
|
|
2015-10-20 12:20:42 +09:00
|
|
|
var cookieDomain = document.domain === "localhost" ? "none" : "auto";
|
|
|
|
|
|
|
|
window.ga('create', googleAnalyticsId, cookieDomain);
|
2013-10-30 08:27:44 +09:00
|
|
|
|
2015-03-28 18:30:26 +09:00
|
|
|
}
|
2013-02-28 09:19:08 +09:00
|
|
|
|
2015-10-20 11:55:22 +09:00
|
|
|
// trigger first request once analytics are initialized
|
|
|
|
Events.analyticsRequest();
|
|
|
|
|
|
|
|
};
|
2012-12-11 10:47:11 +09:00
|
|
|
|
2016-06-05 11:33:25 +09:00
|
|
|
Events.analyticsInit();
|
|
|
|
|