diff --git a/src/models/global.js b/src/models/global.js index 87d6e1a7ad646574527a4d130e3a4b270f367212..91127ed2cc0cc90be29a66faaf267d1bdd88d53e 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); + } + }); + }, + }, };