From 541128ec969e7b249b4bf6df7f577319ab33bd67 Mon Sep 17 00:00:00 2001 From: afc163 Date: Wed, 1 Nov 2017 22:41:16 +0800 Subject: [PATCH] Add ga listener --- src/models/global.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/models/global.js b/src/models/global.js index 87d6e1a7..91127ed2 100644 --- a/src/models/global.js +++ b/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); + } + }); + }, + }, }; -- GitLab