Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/firstandthird/ga-nav-tracker
Auto-track link clicks for Google Analytics
https://github.com/firstandthird/ga-nav-tracker
front-end tracking
Last synced: 3 days ago
JSON representation
Auto-track link clicks for Google Analytics
- Host: GitHub
- URL: https://github.com/firstandthird/ga-nav-tracker
- Owner: firstandthird
- License: mit
- Created: 2018-09-05T20:35:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T20:51:06.000Z (about 2 years ago)
- Last Synced: 2024-04-30T03:46:17.459Z (9 months ago)
- Topics: front-end, tracking
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/ga-nav-tracker
- Size: 1.34 MB
- Stars: 1
- Watchers: 4
- Forks: 1
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Google Analytics Nav Tracker (ga-nav-tracker)
[![Build Status](https://travis-ci.org/firstandthird/ga-nav-tracker.svg?branch=master)](https://travis-ci.org/firstandthird/ga-nav-tracker)
![npm](https://img.shields.io/npm/v/ga-nav-tracker.svg)Auto-track link clicks for Google Analytics.
> This library uses [ga-track](https://github.com/firstandthird/ga-track) and needs [Google Analytics](https://developers.google.com/analytics/devguides/collection/analyticsjs/) to be set up in order to work.
## Installation
```sh
npm install ga-nav-tracker
```## Usage
```js
import GANavTracker from 'ga-nav-tracker'
```### init()
Initializes library and all link clicks within the specified tag will be tracked in Google Analytics.
## Example [(see example)](example/index.html)
Add `data-nav-tracker="header|footer"` to any element and the library will track link clicks.
```html
```
Clicking on the first link will be send this object to Google Analytics:
```js
{
action: 'header'
label: 'Link 1'
category: 'nav-tracker'
}
```
You can optionally set `data-nav-tracker-dropdown`, which prepends tracker location to the label property. See the example below:
```html
```
Clicking on the second link will send this object to Google Analytics:
```js
{
action: 'header'
label: 'Dropdown - Link 2'
category: 'nav-tracker'
}
```
## License
### MIT License
Copyright (c) 2019 First+Third
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.