Skip to content

Instantly share code, notes, and snippets.

@trezy
Last active February 28, 2017 16:26
Show Gist options
  • Save trezy/47e49f88fdb5e129b2b539af6bbf466b to your computer and use it in GitHub Desktop.
Save trezy/47e49f88fdb5e129b2b539af6bbf466b to your computer and use it in GitHub Desktop.
Handling Google Analytics with Next.js
import React from 'react'
export default Head extends React.Component {
componentWillMount () {
ga.push(location.pathname) // This probably isn't quite right, but you get the idea.
}
render () {
<div>
<script dangerouslySetInnerHTML={{__html: 'GA Snippet'}} />
</div>
}
}
import React from 'react'
import Head from './Head'
export defalt Index extends React.Component {
render () {
return (
<div>
<Head />
... page stuff ...
</div>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment