Created
June 13, 2017 01:16
-
-
Save mori-dev/653d2a5a2b7b4fc17d731804b1fb8a1c to your computer and use it in GitHub Desktop.
ブログ記事「React.js/redux アプリでの Google Analytics のイベントトラッキングの設定」の補足コード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createMiddleware } from 'redux-beacon'; | |
import { logger } from 'redux-beacon/extensions/logger'; | |
import { GoogleAnalytics } from 'redux-beacon/targets/google-analytics'; | |
// Redux Beacon EventDefinition | |
// イベントトラッキング: https://developers.google.com/analytics/devguides/collection/analyticsjs/events?hl=ja | |
export const GAEvents = { | |
C1_A1_L1: { | |
eventFields: (action: any) => ({ | |
hitType: 'event', | |
eventCategory: 'C1', | |
eventAction: 'A1', | |
eventLabel: 'L1', | |
}) | |
}, | |
} | |
// キーはアクション名 | |
const eventsMap = { | |
GA_FOO: GAEvents.C1_A1_L1, | |
}; | |
const googleAnalytics = createMiddleware( | |
eventsMap, | |
GoogleAnalytics, | |
{ logger } | |
); | |
export default googleAnalytics; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment