kvandake / next-ym

Next.js HOC to integrate Yandex.Metrica on every page change

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

Next.js HOC to integrate Yandex.Metrica on every page change

License:MIT License


Languages

Language:JavaScript 100.0%