Socket
Socket
Sign inDemoInstall

@socialgouv/matomo-next

Package Overview
Dependencies
Maintainers
4
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@socialgouv/matomo-next

Matomo analytics for Next.js applications. Will track route changes and custom events.


Version published
Weekly downloads
15K
decreased by-5.85%
Maintainers
4
Weekly downloads
 
Created
Source

matomo-next Github Master Main Status License: Apache-2.0 Npm version

Matomo analytics for Next.js applications. Will track route changes and custom events.

Usage

A sample this to your _app.js :

import React from "react";
import App from "next/app";

import { init } from "@socialgouv/matomo-next";

const MATOMO_URL = process.env.NEXT_PUBLIC_MATOMO_URL;
const MATOMO_SITE_ID = process.env.NEXT_PUBLIC_MATOMO_SITE_ID;

class MyApp extends App {
  componentDidMount() {
    init({ url: MATOMO_URL, siteId: MATOMO_SITE_ID });
  }
  render() {
    const { Component, pageProps } = this.props;
    return <Component {...pageProps} />;
  }
}

export default MyApp;

Will track routes changes by default.

You can also track additionnal events :

import { push } from "@socialgouv/matomo-next";

// track some events
push(["trackEvent", "contact", "click phone"]);

Tests

init
  ✓ should create a js tag and initialize (13 ms)
push
  ✓ should append data to window._paq (1 ms)
router.routeChangeComplete event
  ✓ should trackPageView with correct title on route change (4 ms)
  ✓ should use previousPath as referer on consecutive route change (6 ms)

FAQs

Package last updated on 15 May 2020

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc