npm package: @selinarnd/selina-attribution
Description: Module to accept traffic with marketing identifiers and keep them for later use
Author: Anderson LM
Latest version: 1.3.3

# Selina Attribution Module

The goal is to be able to know the history of all the user visits once he makes a booking or other significant events.
The module would be responsible to capture and calculate marketing parameters and identifiers for every user session in an array / local storage (each session is added to the array). 

## Parameters

| Parameter | Type | Origin | Description/Example |
|-------------|--------|---------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| visitDate | string | GMT date/time of the entry to the website |  |
| campId | number | Get from URL query string camp_id | This is the campaign identifier in the back office.Example: http://selina.com/?camp_id=123 |
| utmSource | string | Get from URL query string utm_source | http://selina.com/?utm_source=GoogleExamples: Google/Facebook/NomadicMatt |
| utmCampign | string | Get from URL query string utm_campaign |  |
| utmContent | string | Get from URL query string utm_content |  |
| utmTerm | string | Get from URL query string utm_term |  |
| gclid | string | Get from URL query string gclid |  |
| fbclid | string | Get from URL query string fbclid |  |
| gaId | string | Get from first party cookie created by google analytics | The cookie name is `_ga` |
| userAgent | string | Take from the http header | The full as-is user agent string, where it exists |
| referrer | string | Taken from the browser referrer |  |
| landingPage | string | Page in which the visitor starts his session |  |
| campData | json | Taken from the query string as is, if it’s a valid json | E.g https://www.selina.com/?camp_data=%7B%22campaign%22%3A%22google%20black%20friday%22%2C%20%22affiliate_name%22%3A%22buba%22%7D |

### Extra parameters

The module will add in the response any value data in: `window._selinaAttributionConfig.extraParams = {...}`

### Storage

The module will try to use 'localStorage' ('sessionStorage' if it isn't available), it can be overrided with any compatible method in: `window._selinaAttributionConfig.storage`

### Methods
SelinaAttribution module expose these methods to the console:

#### getAllTouchpoints
Return the object with an array of all the user touchpoints formated.

#### getCurrentTouchpoint 
Return the current visit list of parameters formated.

## Development

### Build 
```sh
npm i
npm run build
```

### Test 
```sh
npm i
npm run test
```

## Git

### Commit

This project use the [conventional change log](https://github.com/conventional-changelog/conventional-changelog) and the [angular commit format](https://gist.github.com/stephenparish/9941e89d80e2bc58a153) to automatically generate the [changelog](/CHANGELOG) file, to help the developers to follow the convetion we use [commitizen](http://commitizen.github.io/cz-cli/) throught the command: 

```
npm run commit
```

if you are contributing this project please use this instead of ```git commit```


### Auto fix linter errors:

Before each commit a pre hook check with [eslinter](https://www.npmjs.com/package/eslinter) the changed files in the commit, if you get an linter error you can try to autofixed with:

```
npm run fixlint
```

### Contributing

Before contribute please check our [contributing guidelines](/CONTRIBUTING)