Explorar o código

Add ga listener

afc163 %!s(int64=8) %!d(string=hai) anos
pai
achega
541128ec96
Modificáronse 1 ficheiros con 11 adicións e 0 borrados
  1. 11 0
      src/models/global.js

+ 11 - 0
src/models/global.js

@@ -62,4 +62,15 @@ export default {
       };
     },
   },
+
+  subscriptions: {
+    setup({ history }) {
+      // Subscribe history(url) change, trigger `load` action if pathname is `/`
+      return history.listen(({ pathname, search }) => {
+        if (typeof window.ga !== 'undefined') {
+          window.ga('send', 'pageview', pathname + search);
+        }
+      });
+    },
+  },
 };