Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ブログ記事「React.js/redux アプリでの Google Analytics のイベントトラッキングの設定」の補足コード
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
You can’t perform that action at this time.