Analytics integration for Redux and ngrx/store
Features
- Integrate with any analytics service, including:
- Google Analytics
- Google Tag Manager
- Segment.io
- Track analytics offline
- Decouple analytics logic from app logic
Installation
npm install --save redux-beacon
Demo
Quick Start
How it works
Redux Beacon maps redux/ngrx actions to analytics events then sends them to a target (e.g. Google Analytics).
Analytics events are defined in an event definition, and mapped to actions in an event definitions map:
// Event Definition
const pageView = {
eventFields: action => ({
hitType: 'pageview',
page: action.payload,
}),
};
// Event Definitions Map
const eventsMap = {
LOCATION_CHANGE: pageView,
}
With the event definitions map above Redux Beacon will create a pageView
event
whenever redux/ngrx dispatches a LOCATION_CHANGE
action, then it will push the
generated analytics event to a target (e.g. Google Analytics).
Built-In Targets
- Google Analytics
- Google Tag Manager
- Segment.io
- Amplitude
- (React Native) Google Analytics
- (React Native) Google Tag Manager
Docs
Check out the project site for API docs, tutorials, examples and more.