-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathanalytics.js
More file actions
63 lines (58 loc) · 1.49 KB
/
analytics.js
File metadata and controls
63 lines (58 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import ReactGA from 'react-ga'
import ReactPixel from 'react-facebook-pixel'
import config from 'constants/config'
import posthog from 'posthog-js'
const AnalyticsService = {}
AnalyticsService.init = () => {
if (config.POSTHOG_API_KEY) {
posthog.init(config.POSTHOG_API_KEY, { api_host: config.POSTHOG_API_HOST })
}
}
AnalyticsService.pageView = location => {
if (config.POSTHOG_API_KEY) {
posthog.capture('$pageview', { path: location.pathname })
}
}
AnalyticsService.events = {
LOG_IN: () => {
posthog.capture('CompleteRegistration', {
value: 0.1,
currency: 'EUR',
})
},
VIEW_EVENT: slug => {
posthog.capture('ViewContent', {
value: 0.1,
currency: 'EUR',
content_ids: slug,
content_type: 'product',
})
},
BEGIN_REGISTRATION: slug => {
posthog.capture('AddToCart', {
value: 0.5,
currency: 'EUR',
contents: [
{
id: slug,
quantity: 1,
},
],
content_ids: slug,
})
},
COMPLETE_REGISTRATION: slug => {
posthog.capture('Purchase', {
value: 1,
currency: 'EUR',
contents: [
{
id: slug,
quantity: 1,
},
],
content_ids: slug,
})
},
}
export default AnalyticsService