2.3.5 • Published 5 years ago

next-ym v2.3.5

Weekly downloads
77
License
MIT
Repository
github
Last release
5 years ago

next-ym

Next.js High Order Component to integrate Yandex.Metrika on every page change.

Usage

Install it

yarn add next-ym

Import it inside your pages/_app.js;

import Router from "next/router";
import withYM from "next-ym";

Wrap your custom App container with it

// pass your YM code as first argument
export default withYM("XXXXXXXX", Router)(MyApp);

That's it, now when the user access a page it will log a pageview to Yandex.Metrika, each page change after that will also trigger a pageview on Yandex.Metrika.

Note: This module detects if it's running in localhost and do nothing there to avoid polluting your analytics with local data.