Redux Beacon
  • Introduction
  • Getting Started (Redux)
  • Getting Started (ngrx)
  • Examples & Recipes
  • Targets
    • GoogleAnalytics
    • GoogleAnalyticsGtag
    • GoogleTagManager
    • Segment
    • Amplitude
    • React Native: GoogleAnalytics
    • React Native: GoogleTagManager
    • React Native: Segment
  • API Reference
    • createMiddleware
    • createMetaReducer
    • EventDefinition
    • EventsMap
    • EventsMapper
  • Extensions
    • logger
    • OfflineWeb
    • OfflineReactNative
  • Utils
    • debounceEvent
    • ensure
    • combineEvents
  • FAQ
  • Migration Guide (v1 to v2)
  • Notes on Offline Events
Powered by GitBook
On this page
  • Setup
  • Usage
  • Event Definitions
  • event
  • userId
  • logout
  • userProperties
  1. Targets

Amplitude

PreviousSegmentNextReact Native: GoogleAnalytics

Last updated 7 years ago

Setup

  1. Sign up for Amplitude at and make a note of your API key.

  2. Install : npm install --save amplitude-js.

  3. Install the target:

     npm install --save @redux-beacon/amplitude

Usage

import amplitude from 'amplitude-js';
import Amplitude from '@redux-beacon/amplitude';

// Create or import an events map.
// See "getting started" pages for instructions.

// initialise amplitude
const amplitudeInstance = amplitude.getInstance();
amplitudeInstance.init('YOUR_API_KEY')

const target = Amplitude({ instance: amplitudeInstance });

const amplitudeMiddleware = createMiddleware(eventsMap, target);
const amplitudeMetaReducer = createMetaReducer(eventsMap, target);

Event Definitions

event

Docs:

import { logEvent } from '@redux-beacon/amplitude';

const event = logEvent((action, prevState, nextState) => {
  return {
    type: /* fill me in */,
    properties: /* (optional) */,
  };
});

userId

Docs:

import { setUserId } from '@redux-beacon/amplitude';

const event = setUserId((action, prevState, nextState) => {
  return /* (user Id) fill me in */
});

logout

Docs:

import { logout } from '@redux-beacon/amplitude';

const event = logout();

userProperties

Docs:

import { setUserProperties } from '@redux-beacon/amplitude';

const event = setUserProperties((action, prevState, nextState) => {
  return {
   [/* property key */]: /* property value */,
  };
});

Don't see your event listed? Please submit a pull request to the with the missing event. Use the source of the existing event-helpers to guide your work. If you need any support feel free to make the pull request with all you're able to do. We can fill in the gaps from there.

Redux Beacon repository
https://amplitude.zendesk.com/hc/en-us/articles/115001361248#tracking-events
https://amplitude.zendesk.com/hc/en-us/articles/115001361248#setting-event-properties
https://amplitude.zendesk.com/hc/en-us/articles/115001361248#setting-custom-user-ids
https://amplitude.zendesk.com/hc/en-us/articles/115001361248#logging-out-and-anonymous-users
https://amplitude.zendesk.com/hc/en-us/articles/115001361248#setting-multiple-user-properties
http://amplitude.com
amplitude-js
Setup
Usage
Event Definitions
event
userId
logout
userProperties