Last active
February 27, 2018 14:47
-
-
Save mwq27/a17c77ae2a889ed0f64ae8ceed05a303 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const trackingMiddleware = (store: Store<any>) => (next: Dispatch<any>) => (action: Action) => { | |
| if (action.type === '@@router/LOCATION_CHANGE') { | |
| const nextPage = `${action.payload.pathname}${action.payload.search}`; | |
| trackPage(nextPage, store.getState()); | |
| } | |
| return next(action); | |
| }; | |
| function trackPage(page: string, state: any) { | |
| ReactGA.set({ | |
| page, | |
| ...options, | |
| }); | |
| ReactGA.pageview(page); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment