Thinking
metrics on

React apps@jcemer
I work on
GloboPlay.

globo.com
React Router 2.0
& Server side
render & Client
side user login
1. How can we 

track our traffic
with Google
Analytics?
<PageView 

location={this.props.location} />
@PureRender
class PageView extends Component {
static propTypes = {
location: PropTypes.object.isRequired
}
componentDidMount() {
const { action, state } = this.props.location
trackPageView(action, state)
}
componentDidUpdate() { /* */ }
}
2. How can we 

analyse custom
data?
Global
metrics data:

user account info
& app version
<DocumentMetrics 

data={{ appVersion: "2.3" }} />
function handleStateChangeOnClient(vars) {
setMetricsDataLayer(vars)
}
export default withSideEffect(
reducePropsToState,
handleStateChangeOnClient
)(DocumentMetrics)
https://github.com/
gaearon/react-side-effect
3. How can we
track the user
navigation flow?
Playlist
Recommendation
Component
metrics:

playlist or

other lists
<Playlist />
<Recommendation />
<Video />is a list of
<Video />is a list of
<Playlist />
<Recommendation />
<Video 

metrics="playlist" />
is a list of
<Video 

metrics="recommendation" />
is a list of
<LinkMetrics data="playlist">
<Playlist />
</LinkMetrics>
https://facebook.github.io/
react/docs/context.html
class Video extends Component {
static contextTypes = {
linkMetrics: PropTypes.object
}
render() {
const state = {
metrics: this.context.linkMetrics
}
return <Link state={state}>/* ... */</Link>
}
}
* redux should be 

an option too
Components
React side effect
Context
Thank you!@jcemer

Thinking metrics on React apps