Skip to content

Instantly share code, notes, and snippets.

@asamountain
Created December 23, 2019 03:23
Show Gist options
  • Select an option

  • Save asamountain/e27f943bcbc175b35f76b4f762c172e8 to your computer and use it in GitHub Desktop.

Select an option

Save asamountain/e27f943bcbc175b35f76b4f762c172e8 to your computer and use it in GitHub Desktop.
practical way to set up Google Analytics Verification in nextJs
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)
@asamountain
Copy link
Author

jumped from here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment