define(['json!/api/v1/client-config'], function (config) {

  if (!(config && config.ga_token)
      || (typeof window === 'undefined')
      || ("localhost" === window.location.hostname)) {
    console.debug("Skipping analytics");
    return function () {}; // NO-OP function.
  }

  (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');

  ga('create', config.ga_token, 'auto');

  return function () {
    // Need to wrap as we cannot return a reference to the analytics.
    ga.apply(null, arguments);
  };

});

define(['json!/api/v1/client-config'], function (config) {

  if (!(config && config.ga_token)
      || "localhost" == window.location.hostname) {
    console.debug("Skipping analytics");
    return function () {}; // NO-OP function.
  }

  (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');

  ga('create', config.ga_token, 'auto');

  return ga;

});

--- 
+++ 
@@ -1,7 +1,8 @@
 define(['json!/api/v1/client-config'], function (config) {
 
   if (!(config && config.ga_token)
-      || "localhost" == window.location.hostname) {
+      || (typeof window === 'undefined')
+      || ("localhost" === window.location.hostname)) {
     console.debug("Skipping analytics");
     return function () {}; // NO-OP function.
   }
@@ -13,6 +14,9 @@
 
   ga('create', config.ga_token, 'auto');
 
-  return ga;
+  return function () {
+    // Need to wrap as we cannot return a reference to the analytics.
+    ga.apply(null, arguments);
+  };
 
 });
Make analytics work with require.js
