Created
December 23, 2019 03:23
-
-
Save asamountain/e27f943bcbc175b35f76b4f762c172e8 to your computer and use it in GitHub Desktop.
practical way to set up Google Analytics Verification in nextJs
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 App, { Container } from 'next/app' | |
| import Router from 'next/router' | |
| import React from 'react' | |
| import withGA from 'next-ga' | |
| import keys from '../config/keys' | |
| class MyApp extends App { | |
| static async getInitialProps({ Component, router, ctx }) { | |
| let pageProps = {} | |
| if (Component.getInitialProps) { | |
| pageProps = await Component.getInitialProps(ctx) | |
| } | |
| return { pageProps } | |
| } | |
| render() { | |
| const { Component, pageProps } = this.props | |
| return ( | |
| <Container> | |
| <Component {...pageProps} /> | |
| </Container> | |
| ) | |
| } | |
| } | |
| export default withGA(keys.gaTrackID, Router)(MyApp) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
jumped from here