@livechat/store-metrics
Reads and stores various marketing parameters as cookies. Super Important Thing for Marketing Team™.
Installation
npm install --save @livechat/store-metrics
Usage
Apps
Library exposes only one function that creates subdomain scoped cookies (*.example.com
) based on document.location
and document.referrer
. Make sure to fire it as early as possible, before redirects etc.
import storeMetrics from "@livechat/store-metrics";
storeMetrics();
NOTE: store-metrics
makes use of URL API. Polyfill for older browser is highly encouraged. We do not bundle any, as your app may already use some polyfill. However, we recommend inexorabletash/polyfill:
npm install --save js-polyfills
import "js-polyfills/url";
Websites
For websites without module bundler/resolver you can use self-executing version of store-metrics that comes bundled with URL API polyfill. You can load it directly from our CDN:
<script src="https://cdn.livechat-static.com/metrics/store-metrics.min.js" async></script>
And that's it.
Development
npm install
npm test:watch
Build
npm run build
Changelog
0.2.0 - 2018-02-13
Added
- Return params which were saved while executing
0.1.4 - 2017-12-12
Fixed
- Referrer for internal redirects is no longer stored
0.1.3 - 2017-12-08
Added
- Self-executing version for browsers
- CDN deployment and website usage docs
Fixed
- URL is not a constructor error
0.1.2 - 2017-12-05
Fixed
- Cookie domain for origins not starting with
www.
0.1.1 [YANKED]
0.1.0 - 2017-11-28
Initial release