Run Function on Every State Change

I am integrating Mixpanel Analytics into my app and I want to track every page change and be able to submit some additional parameters.

I want to run something similar to this:
mixpanel.track("Page Change", {"state":$state.current.name})
on every state change. What is the best way to do this?

UPDATE
The answer can be found here: http://stackoverflow.com/questions/39681137/ionic-run-function-on-every-state-change