Closed Robinnnnn closed 8 years ago
You could use a history listener instead. Theres an example here for React Router - https://github.com/tcoopman/ga-react-router. Updated for redux-rotuer (untested):
import { createHistory } from 'history';
const history = createHistory()
// Listen for changes to the current location. The
// listener is called once immediately.
const unlisten = history.listen(location => {
ga('send', location);
});
// Configure reducer to store state at state.router
// You can store it elsewhere by specifying a custom `routerStateSelector`
// in the store enhancer below
const reducer = combineReducers({
router: routerStateReducer,
//app: rootReducer, //you can combine all your other reducers under a single namespace like so
});
// Compose reduxReactRouter with other store enhancers
const store = compose(
applyMiddleware(m1, m2, m3),
reduxReactRouter({
routes,
history
}),
devTools()
)(createStore)(reducer);
React.render(<ReduxRoute/>, el)
thanks for posting that example, got it working.
Is it possible to log the current window location every time there's a route change?
I know this is possible in
react-router
using an onUpdate handler. ReduxRouter doesn't come with such a handler. Could I set up some middleware somehow in my store?