Socket
Book a DemoInstallSign in
Socket

next-simple-google-analytics

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package version was removed
This package version has been unpublished, mostly likely due to security reasons

next-simple-google-analytics

Add Google Analytics to your Next.js site in a jiffy

unpublished
Source
npmnpm
Version
1.1.2
Version published
Weekly downloads
25
177.78%
Maintainers
1
Weekly downloads
 
Created
Source

next-simple-google-analytics

package version package downloads standard-readme compliant package license make a pull request

Add Google Analytics to your Next.js site in a jiffy

Table of Contents

About

This module is heavily based on the official example.

Usage

Add the default export to the Head of _document.js:

import Document, { Html, Head, Main, NextScript } from 'next/document'
import GoogleAnalytics from 'next-simple-google-analytics'

class MainDocument extends Document {
  static async getInitialProps (ctx) {
    const initialProps = await Document.getInitialProps(ctx)
    return { ...initialProps }
  }

  render () {
    return (
      <Html lang='en'>
        <Head>
          <GoogleAnalytics id="UA-X00XXX0X-X"/>
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    )
  }
}

export default MainDocument
import GoogleAnalytics from 'next-simple-google-analytics'

GoogleAnalytics.pageview('/foo/bar', {
  foo: true
})

GoogleAnaltyics.event('didthing', {
 category, label, value
})

Route changes are required using routeChangeComplete.

Install

This project uses node and npm.

$ npm install next-simple-google-analytics
$ # OR
$ yarn add next-simple-google-analytics

Contribute

  • Fork it and create your feature branch: git checkout -b my-new-feature
  • Commit your changes: git commit -am "Add some feature"
  • Push to the branch: git push origin my-new-feature
  • Submit a pull request

License

MIT © Tiaan du Plessis

Keywords

nextjs

FAQs

Package last updated on 24 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts