From bef1ab8e0bdb186d86124c9df6e89629b981dff2 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Wed, 30 Oct 2013 08:27:44 +0900 Subject: [PATCH] working on google analytics --- client/helpers/analytics.js | 9 ++++++--- client/main.js | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/client/helpers/analytics.js b/client/helpers/analytics.js index 9571b0361..f8e3b91e7 100644 --- a/client/helpers/analytics.js +++ b/client/helpers/analytics.js @@ -1,4 +1,5 @@ analyticsInit = function() { + // Mixpanel if (mixpanelId=getSetting("mixpanelId")){ (function (c, a) { @@ -57,21 +58,23 @@ analyticsInit = function() { } // Google Analytics - if ((googleAnalyticsId = getSetting("googleAnalyticsId"))){ + if (googleAnalyticsId = getSetting("googleAnalyticsId")){ + window._gaq = window._gaq || []; - _gaq.push(['_setAccount', googleAnalyticsId]); + window._gaq.push(['_setAccount', googleAnalyticsId]); (function() { 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'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); + } } analyticsRequest = function() { - + // Google Analytics if (googleAnalyticsId = getSetting("googleAnalyticsId") && window._gaq){ window._gaq.push(['_trackPageview', window.location.pathname]); diff --git a/client/main.js b/client/main.js index df8f8b029..bc3fad66f 100644 --- a/client/main.js +++ b/client/main.js @@ -16,6 +16,7 @@ Session.set('settingsLoaded', false); Meteor.subscribe('settings', function(){ // runs once after settings have loaded Session.set('settingsLoaded',true); + analyticsInit(); }); // Categories @@ -32,4 +33,5 @@ if(Meteor.user() != null) STATUS_PENDING=1; STATUS_APPROVED=2; -STATUS_REJECTED=3; \ No newline at end of file +STATUS_REJECTED=3; +