# How to use an Analytics Provider

This article describes the workflows to integrate Analytics providers to a tenant.

Living standard

The workflows described in this article are subject to change as the rollout progresses. Ask BERG if you have any doubt!

# Working with Legacy tenants

Analytics Providers are not compatible with Legacy tenants.

# Working with XPlib tenants

  1. Install the analytics provider as a package dependency by executing the following command in the Media Group root directory:
npm install @marfeel/analytics-providers-THE_ANALYTICS_PROVIDER_YOU_NEED@latest --save
  1. Create or go to the file analytics.json inside the tenant's resources directory.

  2. Configure the Analytics Provider inside the analytics.json using the properties found in its schema. The object key must be the same as the repository removing analytics-provider:

analytics-provider-googleanalytics becomes googleanalytics.

{
    "googleanalytics": [
        {
          "vars": {
            "account": "XXXXXX"
          }
        }
    ]
}

Schema example for Google Analytics (opens new window).

  1. To add custom variables and page metadata to the analytics calls, check the in-depth explanation of how to use middlewares in an anlytics provider.

  2. Test the analytics provider by observing the Network tab of your browser's dev tools: the same requests as on the tenant's original's site must be triggered by the same events.