Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
react-router-ga
Advanced tools
[![Downloads](https://img.shields.io/npm/dm/react-router-ga)](https://npm.im/react-router-ga) [![Version](https://img.shields.io/npm/v/react-router-ga)](https://npm.im/react-router-ga) [![License](https://img.shields.io/npm/l/react-router-ga)](https://ope
Google Analytics component for React Router. Bear in mind this is a super simple implementation that only logs page views. Logging of custom events, exceptions, user timings or social interactions is currently not supported.
Prop | Type | Description | Default value |
---|---|---|---|
id | string | Google Analytics tracking ID | Required |
basename | string | If provided, react-router-ga will prepend the basename to the pathname of each page view. (This should match the basename provided to the React Router BrowserRouter component. See here for documentation.) | - |
debug | boolean | If enabled, react-router-ga will log all page views to the console | false |
trackPathnameOnly | boolean | If enabled, react-router-ga will only send page views when the pathname changed | false |
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';
import Analytics from 'react-router-ga';
import { Home, Login, NoMatch } from './components';
ReactDOM.render(
<BrowserRouter>
<Analytics id="UA-123456789-0" debug>
<Switch>
<Route exact path="/" component={Home}/>
<Route exact path="/login" component={Login} />
<Route component={NoMatch} />
</Switch>
</Analytics>
</BrowserRouter>,
document.getElementById('root')
);
You can also have a look at the demo app in the example
directory. This app is bootstrapped with create-react-app and is making use of both react-router and react-router-ga.
Probably the code sample you are looking for is in the example/src/index.js
file.
This project has react@^16.0.0
and react-router-dom@^4.0.0
as peer dependencies.
FAQs
[![Downloads](https://img.shields.io/npm/dm/react-router-ga)](https://npm.im/react-router-ga) [![Version](https://img.shields.io/npm/v/react-router-ga)](https://npm.im/react-router-ga) [![License](https://img.shields.io/npm/l/react-router-ga)](https://ope
The npm package react-router-ga receives a total of 524 weekly downloads. As such, react-router-ga popularity was classified as not popular.
We found that react-router-ga demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.