Segment Compatibility

EventNative might be a Segment replacement and has two different configuration approaches depend on your desires. If you have already had configured Segment on your website and you aren't going to replace analytics.js (backend only replacement) - check Intercepting Segment Mode. If you would like to get rid of Segment completely - check Direct Pixel Tracking.

Segment Tables

By default, Segment creates 1 table per 1 event type. For keeping these table names - configure table_name_template like in examples below. Also, Segment creates users table as unique records from identifies table. For keeping it as well - create a SQL view with the following statement:

create view users as
select distinct on (email) _timestamp,
anonymous_id,
email,
user_id,
context_ip,
referrer,
context_user_agent,
path,
url,
title,
context_campaign_source,
context_locale,
context_utm_source
from identifies;

Intercepting Segment Mode

EventNative javascript should be configured according to the following javascript reference and the destination should contain the following mapping configuration:

server:
...
destinations:
destination_to_write_segment_data:
type: ...
...
data_layout:
table_name_template: '{{if eq .event_type "user_identify"}}{{"identifies"}}{{else}}{{.event_type}}{{end}}'
mappings:
keep_unmapped: true #Use true if you would like to have Segment like DB schema + all other fields. Use false for having only Segment data.
fields:
- src: /src_payload/name
dst: /name
action: move
- src: /src_payload/obj/context/page/title
dst: /title
action: move
- src: /src_payload/obj/context/page/url
dst: /url
action: move
- src: /src_payload/obj/userId
dst: /user_id
action: move
- src: /src_payload/obj/anonymousId
dst: /anonymous_id
action: move
- src: /src_payload/obj/context/library/version
dst: /context_library_version
action: move
- src: /src_payload/obj/context/page/referrer
dst: /context_page_referrer
action: move
- src: /src_payload/obj/context/page/url
dst: /context_page_url
action: move
- src: /src_payload/obj/context/page/userAgent
dst: /context_user_agent
action: move
- src: /src_payload/obj/context/page/referrer
dst: /referrer
action: move
- src: /src_payload/obj/context/page/search
dst: /context_page_search
action: move
- src: /src_payload/obj/timestamp
dst: /timestamp
action: move
type: timestamp
- src: /source_ip
dst: /context_ip
action: move
- src: /src_payload/obj/context/library/name
dst: /context_library_name
action: move
- src: /src_payload/obj/messageId
dst: /id
action: move
- src: /src_payload/obj/sentAt
dst: /sent_at
action: move
type: timestamp
- src: /src_payload/obj/context/locale
dst: /context_locale
action: move
- src: /src_payload/obj/context/page/path
dst: /context_page_path
action: move
- src: /src_payload/obj/context/page/title
dst: /context_page_title
action: move
- src: /src_payload/obj/traits/name
dst: /name
action: move
- src: /src_payload/obj/traits/email
dst: /email
action: move

Direct Pixel Tracking

EventNative javascript should be set up, tracking event calls should be placed according to your requirements and the destination should contain the following mapping configuration:

server:
...
destinations:
destination_to_write_segment_data:
type: ...
...
data_layout:
table_name_template: '{{if eq .event_type "user_identify"}}{{"identifies"}}{{else}}{{.event_type}}{{end}}'
mappings:
keep_unmapped: true #Use true if you would like to have Segment like DB schema + all other fields. Use false for having only Segment data.
fields:
- src: /eventn_ctx/utm/campaign
dst: /context_campaign_source
action: move
- src: /app
dst: /app
action: move
- src: /source_ip
dst: /context_ip
action: move
- src: /eventn_ctx/url
dst: /url
action: move
- src: /eventn_ctx/user/internal_id
dst: /user_id
action: move
- src: /eventn_ctx/user_agent
dst: /context_user_agent
action: move
- src: /eventn_ctx/utc_time
dst: /sent_at
action: move
type: timestamp
- src: /eventn_ctx/user_language
dst: /context_locale
action: move
- src: /eventn_ctx/doc_path
dst: /path
action: move
- src: /eventn_ctx/page_title
dst: /title
action: move
- src: /eventn_ctx/user/anonymous_id
dst: /anonymous_id
action: move
- src: /eventn_ctx/referer
dst: /referrer
action: move
- src: /eventn_ctx/user/email
dst: /email
action: move
- src: /eventn_ctx/doc_search
dst: /search
action: move
- src: /eventn_ctx/utm/source
dst: /context_utm_source
action: move