{"id":15043470,"url":"https://github.com/fed/react-router-ga","last_synced_at":"2025-04-14T20:31:18.333Z","repository":{"id":44639431,"uuid":"113680588","full_name":"fed/react-router-ga","owner":"fed","description":"Google Analytics component for React Router","archived":false,"fork":false,"pushed_at":"2022-01-26T23:38:16.000Z","size":1133,"stargazers_count":72,"open_issues_count":6,"forks_count":16,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T09:02:15.006Z","etag":null,"topics":["google-analytics","react","react-component","react-router"],"latest_commit_sha":null,"homepage":"https://npm.im/react-router-ga","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-09T15:41:42.000Z","updated_at":"2024-11-24T10:43:17.000Z","dependencies_parsed_at":"2022-09-12T06:50:57.431Z","dependency_job_id":null,"html_url":"https://github.com/fed/react-router-ga","commit_stats":null,"previous_names":["fknussel/react-router-ga"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fed%2Freact-router-ga","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fed%2Freact-router-ga/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fed%2Freact-router-ga/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fed%2Freact-router-ga/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fed","download_url":"https://codeload.github.com/fed/react-router-ga/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248955514,"owners_count":21189142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["google-analytics","react","react-component","react-router"],"created_at":"2024-09-24T20:49:06.221Z","updated_at":"2025-04-14T20:31:17.631Z","avatar_url":"https://github.com/fed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-router-ga\n\n[![Downloads](https://img.shields.io/npm/dm/react-router-ga)](https://npm.im/react-router-ga)\n[![Version](https://img.shields.io/npm/v/react-router-ga)](https://npm.im/react-router-ga)\n[![License](https://img.shields.io/npm/l/react-router-ga)](https://opensource.org/licenses/MIT)\n\nGoogle 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.\n\n## Props\n\n| Prop | Type | Description | Default value |\n|------|------|-------------|---------------|\n| `id` | string | Google Analytics tracking ID | Required |\n| `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](https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/api/BrowserRouter.md#basename-string) for documentation.) | - |\n| `debug` | boolean | If enabled, react-router-ga will log all page views to the console | `false` |\n| `trackPathnameOnly` | boolean | If enabled, react-router-ga will only send page views when the pathname changed | `false` |\n\n## Usage Example\n\n```jsx\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport { BrowserRouter } from 'react-router-dom';\nimport Analytics from 'react-router-ga';\nimport { Home, Login, NoMatch } from './components';\n\nReactDOM.render(\n  \u003cBrowserRouter\u003e\n    \u003cAnalytics id=\"UA-123456789-0\" debug\u003e\n      \u003cSwitch\u003e\n        \u003cRoute exact path=\"/\" component={Home}/\u003e\n        \u003cRoute exact path=\"/login\" component={Login} /\u003e\n        \u003cRoute component={NoMatch} /\u003e\n      \u003c/Switch\u003e\n    \u003c/Analytics\u003e\n  \u003c/BrowserRouter\u003e,\n  document.getElementById('root')\n);\n```\n\n## Demo App\n\nYou can also have a look at the demo app in the `example` directory. This app is bootstrapped with [create-react-app](https://github.com/facebook/create-react-app/) and is making use of both [react-router](https://github.com/ReactTraining/react-router) and [react-router-ga](https://npm.im/react-router-ga).\n\nProbably the code sample you are looking for is in the [`example/src/index.js` file](https://github.com/fknussel/react-router-ga/blob/master/example/src/index.js#L12-L22).\n\n## Dependencies\n\nThis project has `react@^16.0.0` and `react-router-dom@^4.0.0` as peer dependencies.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffed%2Freact-router-ga","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffed%2Freact-router-ga","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffed%2Freact-router-ga/lists"}