@everymundo/airmodules-event-datalayer

Package for airmodules

Usage no npm install needed!

<script type="module">
  import everymundoAirmodulesEventDatalayer from 'https://cdn.skypack.dev/@everymundo/airmodules-event-datalayer';
</script>

README

EM Logo

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

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
  • viewable-impression
  • search-initiation
  • select-location
  • select-date
  • select-experience
  • change-budget
  • reset-filter
  • sort
Flights
Click to expand list
  • viewable-impression
  • fsi
  • change-origin
  • change-destination
  • change-departure-date
  • change-return-date
  • change-journey-type
  • change-miles
  • expand-form
  • collapse-form
  • sort
  • more-deals
  • open-booking-popup
  • select-tab
  • filter-airlines
  • change-budget
  • change-fare-class
  • collapse-histogram
  • select-month
  • expand-flight
  • reset-filter
  • toggle-farelist
  • expand-map
  • select-map-destination
  • selected-travel-interest
  • zoom
  • select-interest
  • click-out
  • read-article
  • change-month
  • select-location
  • change-location
  • search
  • change-status
  • select-stop

🏁 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 usage can be found in sample.js on Github

For 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

eventObject
 {
  event: "viewable impression",
  module: "emBookingPopup",
  eventAction: "viewable - impression",
  actionLabel: null,
  airlineIataCode: "ul",
  provider: "sri lankan airlines",
  journeyType: "ow",
  originAirportIataCode: "CMB",
  destinationAirportIataCode: "SIN",
  route: "cmb>sin",
  currencyCode: "LKR",
  totalPrice: "5.21",
  totalPriceUSD: null,
  fareClass: "ec",
  departureDate: "03/13/2021",
  returnDate: "2021-06-14",
  daysUntilFlight: "25", //25
  tripLength: 93,
  isFlexibleDates: null,
  discountCode: null,
  deeplinkSiteEdition: null,
  miles: null,
  timestamp: "2021-02-16",
  url: "https://www.srilankan.com/en-lk/",
  passenger: [
    {
      count: 1,
      adultCount: "1",
      youngAdultCount: null,
      childCount: null,
      infantInLapCount: null,
      infantInSeatCount: null,
    },
  ],
  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,
    },
  ],
};


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: ''
}

fsi
Before After

eventObject
{
  event: "fsi",
  module: "emBookingMask",
  eventAction: "fsi",
  actionLabel: 'search flights',
  airlineIataCode: "aa",
  provider: "american airlines",
  journeyType: "rt",
  originAirportIataCode: "CMB",
  destinationAirportIataCode: "SIN",
  route: "cmb>sin",
  currencyCode: "LKR",
  totalPrice: "5.21",
  totalPriceUSD: null,
  fareClass: "b",
  departureDate: "03/13/2021",
  returnDate: "2021-06-14",
  daysUntilFlight: "25", //25
  tripLength: 93,
  isFlexibleDates: null,
  discountCode: null,
  deeplinkSiteEdition: null,
  miles: null,
  timestamp: "2021-02-16",
  url: "https://www.srilankan.com/en-lk/",
  passenger: [
    {
      count: 1,
      adultCount: "1",
      youngAdultCount: null,
      childCount: null,
      infantInLapCount: null,
      infantInSeatCount: null,
    },
  ],
  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,
    },
  ],
};


eventObject
{
  event: 'fsi',
  module: 'em-booking-mask',
  eventAction: 'fsi',
  actionLabel: 'search flights',
  airlineIataCode: 'AA',
  provider: 'AmericanAirlines',
  journeyType: 'ROUND_TRIP',
  originAirportIataCode: 'CMB',
  destinationAirportIataCode: 'SIN',
  route: 'CMB>SIN',
  currencyCode: 'LKR',
  totalPrice: 5.21,
  totalPriceUSD: '',
  fareClass: 'BUSINESS',
  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: ''
}

change-destination
Before After

eventObject
{
  event: "change destination",
  module: "em farelist horizontal tile filterable",
  eventAction: "change - destination",
  actionLabel: null,
  airlineIataCode: "ua",
  provider: "united airlines",
  journeyType: "roundtrip",
  originAirportIataCode: "MIA",
  destinationAirportIataCode: "LAX",
  route: "mia>lax",
  currencyCode: "USD",
  totalPrice: "200.68",
  totalPriceUSD: 200.68,
  fareClass: "ec",
  departureDate: "03/13/2021",
  returnDate: "2021-06-14",
  daysUntilFlight: "25",
  tripLength: "15",
  isFlexibleDates: null,
  discountCode: null,
  deeplinkSiteEdition: null,
  miles: null,
  timestamp: "2021-02-16",
  url: "https://www.testurl.com/",
  passenger: [
    {
      count: 2,
      adultCount: 2,
      youngAdultCount: null,
      childCount: null,
      infantInLapCount: null,
      infantInSeatCount: null,
    },
  ],
  page: [
    {
      siteEdition: "en-US",
      countryIsoCode: "us",
      languageIsoCode: "en",
    },
  ],
  lodging: [
    {
      cityCode: "lax",
      name: "lax",
      startDate: "2021/03/13",
      endDate: "2021-03-20",
      roomCount: 2,
      tripLength: 7,
      starRating: "5",
    },
  ],
};


eventObject
{
  event: 'change-destination',
  module: 'em-farelist-horizontal-tile-filterable',
  eventAction: 'change-destination',
  actionLabel: '',
  airlineIataCode: 'UA',
  provider: 'UnitedAirlines',
  journeyType: 'ROUND_TRIP',
  originAirportIataCode: 'MIA',
  destinationAirportIataCode: 'LAX',
  route: 'MIA>LAX',
  currencyCode: 'USD',
  totalPrice: 200.68,
  totalPriceUSD: 200.68,
  fareClass: 'ECONOMY',
  departureDate: '2021-03-13',
  returnDate: '2021-06-14',
  daysUntilFlight: 25,
  tripLength: 15,
  isFlexibleDates: '',
  discountCode: '',
  deeplinkSiteEdition: '',
  miles: '',
  timestamp: '2021-02-16T00:00:00.000Z',
  url: 'https: //www.testurl.com/',
  passenger: [
    {
      count: 2,
      adultCount: 2,
      youngAdultCount: '',
      childCount: '',
      infantInLapCount: '',
      infantInSeatCount: ''
    }
  ],
  page: [
    {
      siteEdition: 'en-US',
      countryIsoCode: 'US',
      languageIsoCode: 'en'
    }
  ],
  lodging: [
    {
      cityCode: 'LAX',
      name: 'Lax',
      startDate: '2021-03-13',
      endDate: '2021-03-20',
      roomCount: 2,
      tripLength: 7,
      starRating: 5
    }
  ],
  moduleId: '',
  tagName: ''
}

change-departure-date
Before After

eventObject
{
  event: "change-departure-date",
  module: "em-farelist-mosaic-carousel",
  eventAction: "test",
  actionLabel: null,
  airlineIataCode: "A3",
  provider: "Aegean Airlines",
  journeyType: "oneway",
  originAirportIataCode: "ATH",
  destinationAirportIataCode: "FLL",
  route: "ATH>FLL",
  currencyCode: "USD",
  totalPrice: "56",
  totalPriceUSD: "56",
  fareClass: "fc",
  departureDate: "03-13-2021",
  returnDate: "2021/06/14",
  daysUntilFlight: "25",
  tripLength: "15",
  isFlexibleDates: null,
  discountCode: null,
  deeplinkSiteEdition: null,
  miles: null,
  timestamp: "2021-02-16",
  url: "https://www.testurl.com/",
  passenger: [
    {
      count: 2,
      adultCount: 2,
      youngAdultCount: null,
      childCount: null,
      infantInLapCount: null,
      infantInSeatCount: null,
    },
  ],
  page: [
    {
      siteEdition: "en-US",
      countryIsoCode: "us",
      languageIsoCode: "en",
    },
  ],
  lodging: [
    {
      cityCode: "FLL",
      name: "fll",
      startDate: "2021/03/13",
      endDate: "2021-03-20",
      roomCount: "2",
      tripLength: "7",
      starRating: "5",
    },
  ],
};


eventObject
{
  event: 'change-departure-date',
  module: 'em-farelist-mosaic-carousel',
  eventAction: 'change-departure-date',
  actionLabel: '',
  airlineIataCode: 'A3',
  provider: 'AegeanAirlines',
  journeyType: 'ONE_WAY',
  originAirportIataCode: 'ATH',
  destinationAirportIataCode: 'FLL',
  route: 'ATH>FLL',
  currencyCode: 'USD',
  totalPrice: 56,
  totalPriceUSD: 56,
  fareClass: 'FIRST',
  departureDate: '2021-03-13',
  returnDate: '2021-06-14',
  daysUntilFlight: 25,
  tripLength: 15,
  isFlexibleDates: '',
  discountCode: '',
  deeplinkSiteEdition: '',
  miles: '',
  timestamp: '2021-02-16T00:00:00.000Z',
  url: 'https: //www.testurl.com/',
  passenger: [
    {
      count: 2,
      adultCount: 2,
      youngAdultCount: '',
      childCount: '',
      infantInLapCount: '',
      infantInSeatCount: ''
    }
  ],
  page: [
    {
      siteEdition: 'en-US',
      countryIsoCode: 'US',
      languageIsoCode: 'en'
    }
  ],
  lodging: [
    {
      cityCode: 'FLL',
      name: 'Fll',
      startDate: '2021-03-13',
      endDate: '2021-03-20',
      roomCount: 2,
      tripLength: 7,
      starRating: 5
    }
  ],
  moduleId: '',
  tagName: ''
}

change-budget
Before After

eventObject
{
  event: "change budget",
  module: "Em farelist featured destination",
  eventAction: "budget",
  actionLabel: "test",
  airlineIataCode: "TX",
  provider: "AirlineTRFX",
  journeyType: "round trip",
  originAirportIataCode: "MIA",
  destinationAirportIataCode: "FLL",
  route: "mia>FLL",
  currencyCode: "USD",
  totalPrice: "40",
  totalPriceUSD: 40,
  fareClass: "ec",
  departureDate: "03-13-2021",
  returnDate: "2021/06/14",
  daysUntilFlight: 21,
  tripLength: "7",
  isFlexibleDates: null,
  discountCode: null,
  deeplinkSiteEdition: null,
  miles: "500",
  timestamp: "2021/02/16",
  url: "https://www.testurl.com/",
  passenger: [
    {
      count: 2,
      adultCount: 2,
      youngAdultCount: "1",
      childCount:"0",
      infantInLapCount: null,
      infantInSeatCount: null,
    },
  ],
  page: [
    {
      siteEdition: "en-US",
      countryIsoCode: "us",
      languageIsoCode: "en",
    },
  ],
  lodging: [
    {
      cityCode: "FLL",
      name: "fll",
      startDate: "2021/03/13",
      endDate: "2021-03-20",
      roomCount: 2,
      tripLength: "7",
      starRating: "5",
    },
  ],
};

eventObject
{
  event: 'change-budget',
  module: 'em-farelist-featured-destination',
  eventAction: 'change-budget',
  actionLabel: 'test',
  airlineIataCode: 'TX',
  provider: 'Airlinetrfx',
  journeyType: 'ROUND_TRIP',
  originAirportIataCode: 'MIA',
  destinationAirportIataCode: 'FLL',
  route: 'MIA>FLL',
  currencyCode: 'USD',
  totalPrice: 40,
  totalPriceUSD: 40,
  fareClass: 'ECONOMY',
  departureDate: '2021-03-13',
  returnDate: '2021-06-14',
  daysUntilFlight: 21,
  tripLength: 7,
  isFlexibleDates: '',
  discountCode: '',
  deeplinkSiteEdition: '',
  miles: 500,
  timestamp: '2021-02-16T05:00:00.000Z',
  url: 'https: //www.testurl.com/',
  passenger: [
    {
      count: 2,
      adultCount: 2,
      youngAdultCount: 1,
      childCount: 0,
      infantInLapCount: '',
      infantInSeatCount: ''
    }
  ],
  page: [
    {
      siteEdition: 'en-US',
      countryIsoCode: 'US',
      languageIsoCode: 'en'
    }
  ],
  lodging: [
    {
      cityCode: 'FLL',
      name: 'Fll',
      startDate: '2021-03-13',
      endDate: '2021-03-20',
      roomCount: 2,
      tripLength: 7,
      starRating: 5
    }
  ],
  moduleId: '',
  tagName: ''
}

⛏️ Built Using