ePrivacy and GPDR Cookie Consent by Cookie Consent Skip to main content

Meiro Events SDK public interface

MeiroEvents.init({} | string)

Sets an endpoint for events collection and configures other additional things like the external id, The Trade Desk synchronization, or domains for cross-domain tracking. It also: 

  • generates unique user id

  • checks for inbound user ids from URL (cross-domain tracking)

  • appends CSS styles required for web banners functionality.

Input argument can be a string defining ME backend URL or config object with the following structure:

{
  protocol?: "https:", // ME backend server protocol
  domain: "events.meiro.io", // ME backend server domain
  path?: "/events", // Path where ME backend server expects events (default is '/')
  endpoint?: "https://events.meiro.io/events", // specifies the whole ME backend endpoint, 'protocol', 'domain' and 'path' will be ignored in this case
  external_id?: "some-id", // some optional id sent with each event
  the_trade_desk?: { // configuration for The Trade Desk synchronization
    pid: "ttd-pid",
    gdpr?: 0, // can be 1 or 0,
    gdpr_consent?: "some consent string"
  },
  google_pixel: { // configuration for Google pixel
	google_nid: "", // Google Network ID (String)
	},
  cross_domain_whitelist?: ["domain1", "domain2"],
  storage_consents?: { statistics: true }, // optional property that specifies consent by category where true means consent was given and  false means it was not
  sync?: {  // configuration for automatic collection of FB and Google data
    ga_cid: true,
    fb_cid: true
  },
  outbound_link_tracking?: {
    enabled: true,
    domains_blacklist?: ["domain1", "domain2"]
  }
}

MeiroEvents.getUserId(): string | null:

Returns user ID.

MeiroEvents.getSessionId(): string | null:

Returns current session ID.

MeiroEvents.evaluateWebBanners()

Enables the evaluation of web banners when the tracking page views are disabled. To ensure proper functionality, the method should be called with each page view on your website or app.

MeiroEvents.getWebBannerId(): string | null:

Returns visible Pop-Up banner id or null if there isn’t any.

MeiroEvents.getWebBannerName(): string | null:

Returns visible Pop-Up banner name or null if there isn’t any.

MeiroEvents.closePopUpWebBanner({ minimize?: boolean }):

Programmatically closes the visible web banner and dispatches meiro:bannerclose custom JavaScript event. Accepts configuration object with minimize property suitable for web banners with minimized version where you can specify, if you want to minimize web banner or not (default is true).

MeiroEvents.goToWebBannerUrl(url, bannerId):

Programmatically triggers the given web banner click and transitions a user to the given URL. It also dispatches meiro:bannerclick custom JavaScript event and sends web_banner_click event.

MeiroEvents.getWebBannerHttpResponses(bannerId): Response[]:

If the given web banner makes HTTP requests in its conditions tree, the responses are stored for later usage in web banner HTML code (eg. you want to render some personalisation information from a segment API call). You simply don’t have to make the same API call again to get response data and you can access them via this method call. 

The method returns an array of responses in the following format:

[
  {
    url: "https://cdp.meiro.io/wbs?customer_id=abcde&segment_id=5",
    data: {
      ... response data
    }
  },
  ... possibly another banner api calls
]

MeiroEvents.showPopUpWebBanner(bannerId):

Renders Pop-Up banner specified in argument and closes previously displayed Pop-Up banner (if any). It also sends web_banner_impression event.

MeiroEvents.resetIdentity():

Restores all settings defaults and erases all information about the current user, specifically:

  • it closes opened Pop-Up banner (if any)

  • it completely clears storage

  • it removes user id cookies and inbound user ids cookie

  • it generates an entirely new user ID and session ID

Events: Programmatically setting events tracking

MeiroEvents.track(eventType, eventPayload?, bannerId): Promise

The main method used for tracking purposes, available variants are:

Page view:
  • track(“page_view”, { optionalPayload })
    • sends page_view event and evaluates web banners conditions
    • sends custom_event with the given payload

Contact Form Submit:
  • track(“contact_form_submit”, { payload })

    • sends contact_form_submit event with the given payload

Web Banner Click:
  • track(“web_banner_click”, { url: “destination url” }, bannerId)

    • sends web_banner_click event with the given destination URL for banner specified by bannerId

Web Banner Impression:
  • track(“web_banner_impression”, null, bannerId)

    • sends web_banner_impression event for banner specified by bannerId

MeiroEvents.updateStorageConsents({ statistics: boolean })

The method enables users to update the consent configuration at a later time when the customer updates their consent.