README
Tracking Package
The tracking package is used for formatting datalayer object values.
📝 Table of Contents
🧐 About
npm package which exports a formatting function that transforms the event tracking object into a dataLayer format as defined in the emDataStandards. This function then pushes to the dataLayer.
📓 Notes
- The event object should follow the emDataStandards
- The event object should contain as many parameters as possible. Minimum required parameters:
emDataStandards Field | Event Label Parameter | Example |
---|---|---|
provider | p | AmericanAirlines |
url | url | https://aa.com/en-us/flights |
deviceCategory | dct | DESKTOP |
siteEdition | se | en-US |
pageTypeCode | ptc | HP |
airlineIataCode | aic | AA |
emcid | emcid | T-HgP91dNuv |
- The event and eventAction parameter of the event object should have values that belong to the list. Please ensure that the passed value belongs to this list:
Customer Type | Event Actions |
Events |
Click to expand list
|
Flights |
Click to expand list
|
🏁 Getting Started
Use npm to install the Tracking Package.
npm install @everymundo/airmodules-event-datalayer
Usage
import { formatter } from "@everymundo/airmodules-event-datalayer";
Function call
For Airlines:
{
formatter.formatAirlines(eventObject);
}
For Hotels:
{
formatter.formatHotels(eventObject);
}
This section describes the formatter function in detail. Samples can be found below.
sample.js on Github
Sample usage can be found inFor Event customers, view tracking parameters here:
Click to expand table
Event Label Field | Event Label Parameter | emDataStandards Field |
---|---|---|
label (Optional) | l | actionLabel |
provider | p | provider |
url | url | url |
deviceCategory | dct | GA4 Default Value |
siteEdition | se | page.siteEdition |
pageTypeCode | ptc | EM.dataLayer.typeCode |
tenantCode | tnc | tenantCode |
eventName | en | eventName |
eventLocation | el | eventLocation |
eventDate | ed | eventDate |
experience | ex | experience |
ticketCount | tc | ticketCount |
totalPrice | tp | totalPrice |
currencyCode | c | currencyCode |
taxAmount | ta | taxAmount |
totalPriceUSD | tpu | totalPriceUSD |
emcid | emcid | emcid (Cookie) |
Create an object: Note: null values will be replaced with empty ' ' strings. It is ideal to pass values in the format below. Other acceptable input values can be seen in the table.
const eventObject = {
event: 'viewable-impression',
module: 'em-booking-popup',
eventAction: 'viewable-impression',
actionLabel: '',
airlineIataCode: 'UL',
provider: 'SriLankanAirlines',
journeyType: 'ONE_WAY',
originAirportIataCode: 'CMB',
destinationAirportIataCode: 'SIN',
route: 'CMB>SIN',
currencyCode: 'LKR',
totalPrice: 5.21,
totalPriceUSD: '',
fareClass: 'ECONOMY',
departureDate: '2021-03-13',
returnDate: '2021-06-14',
daysUntilFlight: 25,
tripLength: 93,
isFlexibleDates: '',
discountCode: '',
deeplinkSiteEdition: '',
miles: '',
timestamp: '2021-02-16T00:00:00.000Z',
url: 'https: //www.srilankan.com/en-lk/',
passenger: [
{
count: 1,
adultCount: 1,
youngAdultCount: '',
childCount: '',
infantInLapCount: '',
infantInSeatCount: ''
}
],
page: [
{
siteEdition: 'en-LK',
countryIsoCode: 'LK',
languageIsoCode: 'en'
}
],
lodging: [
{
cityCode: 'SIN',
name: 'Intercontinental',
startDate: '2021-03-13',
endDate: '2021-03-20',
roomCount: 2,
tripLength: 7,
starRating: 5
}
],
moduleId: '',
tagName: ''
}
formatAirlines function:
- Checks whether the incoming object includes "module" and "eventAction". If the object does not contain these fields, formatAirlines will add and initialize these with an empty string.
- In the case that countryIsoCode, LanguageIsoCode, siteEdition or name are missing from their parent field, an empty value will be assigned to the respective key
- Pushes to the dataLayer
formatHotels function:
- Checks whether the incoming object includes "module" and "eventAction". If the object does not contain these fields, formatHotels will add and initialize these with an empty string.
- In the case that countryIsoCode, LanguageIsoCode, siteEdition or name are missing from their parent field, an empty value will be assigned to the respective key
- Null values will be converted to empty string
- Pushes to the dataLayer
Field | Accepted Values | Formatted Result |
---|---|---|
journey | oneway, one-way, ow, one way, one_way | ONE_WAY |
roundtrip, round-trip, round_trip, rt, round trip | ROUND_TRIP | |
fareClass | ec, economy, e | ECONOMY |
business, bc, b, businessclass | BUSINESS | |
first, fc, f, firstclass | FIRST | |
provider | String separated by spaces i.e 'sri lankan airlines' | SriLankanAirlines |
departureDate, returnDate, startDate, endDate | Dates separated by spaces, slashes, or dashes i.e 2021/11/04, 2021 11 04, 2021-11-04 or '04 November 2021 5:13 EST' | 2021-11-04 |
timestamp | Dates separated by spaces, slashes, or dashes i.e 2021/11/04, 2021 11 04, 2021-11-04 or '04 November 2021 5:13 EST' | 2021-11-04T10:13:00.000Z |
url | URL string i.e 'https://www.srilankan.com/en-lk/' | https: //www.srilankan.com/en-lk/ |
fields with numeric values or null i.e totalPrice, totalPriceUSD, tripLength etc. | integers, numeric strings, null i.e {"totalPrice": "25"} |
{"totalPrice": 25} Note: Null values are converted to empty string '' |
events, module | String separated by spaces, dashes or camelCased. i.e 'em booking popup' | 'em-booking-popup' |
eventAction | String separated by spaces, dashes or camelCased. i.e 'viewable impression'. Formatted automatically from given event value | 'viewable-impression' |
lodging | String i.e 'intercontinental' | 'Intercontinental' |
siteEdition | String separated by spaces, dashes, slashes or camelCased. i.e 'en-lk' | 'en-LK' |
countryIsoCode | String i.e 'lk' | 'LK' |
languageIsoCode | String i.e 'en' | 'en' |
fields that contain string values i.e currencyCode, originAirportIataCode, destinationAirportIataCode etc. | String i.e 'mia' | 'MIA' |
Event Object Examples
Examples of unformatted objects and their formatted results can be found here.
viewable-impression
Before | After |
|
|
fsi
Before | After |
|
|
change-destination
Before | After |
|
|
change-departure-date
Before | After |
|
|
change-budget
Before | After |
|
|
⛏️ Built Using
- NodeJs - Server Environment