https://github.com/loevgaard/last-click
Save the last external website your visitors clicked
https://github.com/loevgaard/last-click
analytics javascript npm
Last synced: 7 months ago
JSON representation
Save the last external website your visitors clicked
- Host: GitHub
- URL: https://github.com/loevgaard/last-click
- Owner: loevgaard
- License: mit
- Created: 2018-03-23T13:14:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-03T13:38:00.000Z (almost 8 years ago)
- Last Synced: 2025-08-19T04:09:42.096Z (7 months ago)
- Topics: analytics, javascript, npm
- Language: JavaScript
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Last Click - Save the last external website your visitors clicked
[![Software License][ico-license]](LICENSE)
[![Build Status][ico-travis]][link-travis]
[![Coverage Status][ico-scrutinizer]][link-scrutinizer]
[![Quality Score][ico-code-quality]][link-code-quality]
The name 'last click' comes from marketing terms where the last click refers to the last external website a user clicked before arriving on your website.
That external website is what we try to figure out and save in this library.
## Installation
```bash
$ npm install last-click
```
## Usage
```javascript
// these are the default settings used in the library
// you can add more sources if you want
const defaultSettings = {
sources: [
{referrer: 'google'},
{referrer: 'yahoo'},
{referrer: 'bing'},
{queryParameter: 'gclid', 'value': 'adwords'},
{queryParameter: 'utm_source'}
],
cookie: {
name: 'last_click',
expires: 30 * 24 * 60 * 60 // 30 days in seconds
}
};
const lastClick = require('last-click')(defaultSettings);
console.log(lastClick.getLastClick());
```
## Test
```bash
$ npm test
```
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[ico-travis]: https://img.shields.io/travis/loevgaard/last-click/master.svg?style=flat-square
[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/loevgaard/last-click.svg?style=flat-square
[ico-code-quality]: https://img.shields.io/scrutinizer/g/loevgaard/last-click.svg?style=flat-square
[link-travis]: https://travis-ci.org/loevgaard/last-click
[link-scrutinizer]: https://scrutinizer-ci.com/g/loevgaard/last-click/code-structure
[link-code-quality]: https://scrutinizer-ci.com/g/loevgaard/last-click