# Analytics Providers: Marfeel Environment

Analytics Providers receive the Marfeel environment object in the constructor and all trigger methods

Marfeel environment is decorated with specific fields for each provider: this article is about the analytics providers' specificities.

Use Marfeel Environment utilities to:

  • Install scrips
  • Retrieve context information from Marfeel. e.g: navigation level, uri, etc.
  • Retrieve tenant information from Marfeel

# Common fields

All the fields described in this section are common to all providers. You can read more in the Environment implementation (opens new window).

The field consent exposes 2 methods:

  • getGoogleConsent
  • getVendorConsent

To retrieve all the information regarding consent from a tenant.

# location

The field location exposes all the properties of the current location of a session:

  • environment: the Marfeel garda run time environment. Equivalent to the legacy GardaMarfeel.getRuntimeEnvinroment() method.
  • title: the current page title
  • level: the current navigation level. e.g: mosaic, gallery, details
  • hostname: the current hostname
  • href: the current href
  • search: the current query parameters of the page
  • hash: the current hash of the page
  • pathname: the pathname of the page
  • origin: the current origin of the page
  • protocol: the current protocol of the page
  • referrer: the referrer of the page
  • getSection: a function that returns the current section.

Prefer Marfeel Environment

Prefer using Marfeel Environment to using the window object for page information.

# scripts

The field scripts exposes 2 helper methods to install scrips:

  • installScript: Replaces the legacy loadExternalScript method that is used in the legacy metrics.
  • installScriptInNode

# tenant

The field tenant exposes an id which is the publisher's id, like www.example.com

# Analytics-specific fields

In addition to the common fields, a device object is available.

# device

The field device exposes the Marfeel device environment, for example, marfeel_browser.

Read the implementation (opens new window) for more details.