Created
February 15, 2022 13:50
-
-
Save tobimori/857caadf29c125f9ed342ae847c7f5dc to your computer and use it in GitHub Desktop.
Ackee 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 { useEffect } from 'react' | |
import Router from 'next/router' | |
import * as ackeeTracker from 'ackee-tracker' | |
// global styles (css reset, fonts) | |
import 'assets/styles/global.css' | |
const PersonalApp = ({ Component, pageProps, router }) => { | |
useEffect(() => { | |
if (typeof window !== 'undefined') { | |
window.ackeeTrackerInstance = ackeeTracker.create({ | |
server: 'https://analytics.moeritz.io', | |
domainId: 'f20499e5-1784-48db-9182-62814881c486' | |
}, { | |
ignoreLocalhost: true, | |
detailed: true | |
}) | |
window.ackeeTrackerInstance.record() | |
Router.events.on('routeChangeComplete', window.ackeeTrackerInstance.record()) | |
} | |
}, []) | |
return ( | |
<Component {...pageProps} key={router.route} /> | |
) | |
} | |
export default PersonalApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment