UNPKG

4.14 kBMarkdownView Raw
1<p align="center">
2 <a href="https://rangle.github.io/redux-beacon/">
3 <img alt="Redux Beacon" src="https://raw.githubusercontent.com/rangle/redux-beacon/af4a88229194291f6b6c9f5311b86488f6b16f1d/logo/redux-beacon-logomark.png" width="200">
4 </a>
5</p>
6
7<p align="center">
8Analytics integration for Redux and ngrx/store
9</p>
10
11<p align="center">
12 <a href="https://circleci.com/gh/rangle/redux-beacon"><img src="https://img.shields.io/circleci/project/github/rangle/redux-beacon.svg"></a>
13 <a href="https://www.npmjs.com/package/redux-beacon"><img src="https://img.shields.io/npm/v/redux-beacon.svg"></a>
14 <a href="https://github.com/rangle/redux-beacon/blob/master/LICENSE"><img src="https://img.shields.io/github/license/rangle/redux-beacon.svg"></a>
15</p>
16
17## Features
18 * Integrate with _any_ analytics service, including:
19 * Google Analytics
20 * Google Tag Manager
21 * Segment.io
22 * Track analytics offline
23 * Decouple analytics logic from app logic
24
25## Installation
26
27```bash
28npm install --save redux-beacon
29```
30## Demo
31
32<p align="center">
33 <img src="https://cloud.githubusercontent.com/assets/7446702/23868943/b5a26442-07f7-11e7-935a-59048e02eb5b.gif" width="750">
34 <img src="https://cloud.githubusercontent.com/assets/7446702/23869223/949ae1b0-07f8-11e7-93fd-0b904f3660ea.gif" width="750">
35</p>
36
37## Quick Start
38 - [I'm using Redux.](https://rangle.github.io/redux-beacon/docs/quick-start/redux-users.html)
39 - [I'm using ngrx/store.](https://rangle.github.io/redux-beacon/docs/quick-start/ngrx-users.html)
40
41## How it works
42
43<p align="center">
44 <img src="https://cloud.githubusercontent.com/assets/7446702/25776983/852cb482-329c-11e7-8196-e26b8664221c.png" width="600">
45</p>
46
47Redux Beacon maps redux/ngrx actions to analytics events then sends them to a target (e.g. Google Analytics).
48
49Analytics events are defined in an event definition, and mapped to
50actions in an event definitions map:
51
52```js
53// This is an event definition
54const pageView = (action, prevState) => ({
55 hitType: 'pageview',
56 page: action.payload,
57 referrer: prevState.route,
58});
59
60// This is another event definition
61const buttonClick = action => ({
62 hitType: 'event',
63 eventCategory: 'button-click',
64 eventAction: action.type,
65});
66
67// This is how you map event definitions to redux/ngrx actions
68const eventsMap = {
69 LOCATION_CHANGED: pageView,
70 BUTTON_CLICKED: buttonClick,
71}
72```
73
74With the set up above Redux Beacon will create `pageView`, and `buttonClick`
75events whenever redux/ngrx dispatches `LOCATION_CHANGED` or `BUTTON_CLICKED`,
76then it'll push the generated analytics events to a target (e.g. Google
77Analytics).
78
79## Offline Event Collection
80<p align="center">
81 <a href="https://rangle.github.io/redux-beacon/docs/notes-on-offline-events.html">
82 <img src="https://cloud.githubusercontent.com/assets/7446702/25926466/60728c2e-35bd-11e7-85b2-7e265c968202.png" width="700">
83 </a>
84</p>
85
86Redux Beacon provides extensions to help handle intermittent outages in
87connectivity. These extensions place events in a persistent store when offline
88(e.g indexedDB). When back online, the extensions purge the store and pass the
89events off to a target. Read more about offline event collection in the
90[docs](https://rangle.github.io/redux-beacon/docs/extensions/offline-web.html).
91
92## Built-In Targets
93
94 - [Google Analytics](https://rangle.github.io/redux-beacon/docs/targets/google-analytics.html)
95 - [Google Tag Manager](https://rangle.github.io/redux-beacon/docs/targets/google-tag-manager.html)
96 - [Segment.io](https://rangle.github.io/redux-beacon/docs/targets/segment.html)
97 - [Amplitude](https://rangle.github.io/redux-beacon/docs/targets/amplitude.html)
98 - [_(React Native)_ Google Analytics](https://rangle.github.io/redux-beacon/docs/targets/react-native-google-analytics.html)
99 - [_(React Native)_ Google Tag Manager](https://rangle.github.io/redux-beacon/docs/targets/react-native-google-tag-manager.html)
100 - [_(Cordova)_ Google Analytics](https://rangle.github.io/redux-beacon/docs/targets/cordova-google-analytics.html)
101
102## Docs
103Check out the [project site](https://rangle.github.io/redux-beacon/)
104for API docs, tutorials, examples and more.