Socket
Socket
Sign inDemoInstall

next-analytics

Package Overview
Dependencies
2
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    next-analytics

Next.js HOC to integrate analytics tools (GA and FBQ).


Version published
Weekly downloads
88
decreased by-4.35%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

next-analytics

Next.js HOC to integrate analytics tools (GA and FBQ).

Usage

Install it

yarn add next-analytics

Import it inside your pages/_app.js;

import Router from "next/router";
import withAnalytics from "next-analytics";

Wrap your custom App container with it

// pass an object with your Google Analytics and/or Facebook Pixel code as first argument
export default withAnalytics(Router, { ga: "UA-xxxxxxxxx-1", fbq: "139xxxxxxxxx3" })(MyApp);

That's it, now when the user access a page it will log a pageview to Google Analytics and/or Facebook Pixel, each page change after that will also trigger a pageview on GA and/or FBQ.

Note: This module only applies the HOC next-ga or next-fbq if the code is sent when instancing

Credits

Thanks to @joecohens for creating next-fbq.

Keywords

FAQs

Last updated on 17 Aug 2018

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc