Last active
February 28, 2017 16:26
-
-
Save trezy/47e49f88fdb5e129b2b539af6bbf466b to your computer and use it in GitHub Desktop.
Handling Google Analytics with Next.js
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
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> | |
} | |
} |
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
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