Magnolia 6.1 reached end of life on March 31, 2021. This branch is no longer supported, see End-of-life policy.
The Analytics Connector Pack modules provide a framework and connectors to inject your analytics data into the Magnolia UI enabling authors and marketeers to make data-driven decisions.
The overall process to configure a dashboard is:
The pack delivers out-of-the-box connectors, a default Analytics app and extensive predefined samples to help you build your own charts and dashboards.
artifactID | Description |
---|---|
| Parent reactor. |
| Provides a default implementation to connect to amCharts, which provides JavaScript-based interactive charts and maps programming libraries and tools. |
| Provides a default implementation to connect to Google Analytics. |
| Provides a default implementation to connect to Matomo. |
| Provides the foundation and the API for the Analytics add-on. |
| Provides the Analytics app, the |
| Provides sample dashboards. |
Maven is the easiest way to install the modules. Add the following dependencies to your webapp. All the other necessary dependencies will be brought in automatically:
<dependency>
<groupId>info.magnolia.analytics</groupId>
<artifactId>magnolia-analytics-parent</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>info.magnolia.analytics</groupId>
<artifactId>magnolia-analytics-ui</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>info.magnolia.analytics</groupId>
<artifactId>magnolia-analytics-amcharts</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>info.magnolia.analytics</groupId>
<artifactId>magnolia-analytics-google-connector</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>info.magnolia.analytics</groupId>
<artifactId>magnolia-analytics-matomo-connector</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>info.magnolia.analytics</groupId>
<artifactId>magnolia-analytics</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>info.magnolia.analytics</groupId>
<artifactId>magnolia-analytics-amcharts-samples</artifactId>
<version>1.0</version>
</dependency>
The magnolia-analytics-ui
submodule provides a sample Analytics app configuration, the demo dashboard you see in the app and several preconfigured chart types.
The magnolia-analytics-amcharts-samples
provides sample dashboards.
You can create or edit the configuration of the app and the dashboard as part of a light module (YAML).
magnolia.resources.dir/ └── analytics-ui/ ├── apps/ └── analytics.yaml ├── dashboards └── demo.yaml └── i18n/ └── magnolia-analytics-ui-messages_en.properties
Define the data supplier(s) for the charts displayed in the dashboard. You later refer to the supplier in the chart definition dataSupplier
property.
If you need to integrate your own external analytics tool, implement the class AbstractExternalDataSupplier. The Google Analytics data supplier example below extends this generic class with Google Analytics account credentials.
You must have an appropriate account and credentials to connect to GA.
dataSuppliers: googleSupplier: class: info.magnolia.analytics.google.datasource.GoogleDataSupplier credentials: applicationName: Magnolia Analytics serviceAccountJsonPath: /google-analytics/analytics/google/private_key.json parameters: viewId: 191451330 startDate: 7DaysAgo endDate: today dimensionName: ga:date metricExpression: ga:sessions metricAlias: sessions
| |
| required Arbitrary data supplier name. |
| GoogleDataSupplier |
| |
| required Name of the application requesting the data from the Google Analytics reporting service. For example: Magnolia Analytics |
| required Path to JSON file with service account credentials for your Google Analytics Service Account. For example: |
| required The parameters used in the REST call to configure the JSON results retrieved. These parameters vary depending on the data supplier used. Each parameter is a key-value pair. For Google Analytics, at least the See the Google Analytics API documentation (https://developers.google.com/analytics/devguides/reporting/core/dimsmets) to find valid parameters for Google Analytics. |
You must have an appropriate account and credentials to connect to Matomo.
dataSuppliers: matomoSupplier: class: info.magnolia.analytics.matomo.datasource.MatomoDataSupplier credentials: parameters: serverUrl: https://demo.matomo.org tokenAuth: anonymous parameters: method: UserCountry.getCity module: API idSite: 62 date: yesterday period: day format: json filter_limit: 5
| |
| required Arbitrary data supplier name. |
| required MatomoDataSupplier |
| |
| |
| required The URL to your Matomo server. |
| required |
| required The parameters used in the REST call to configure the JSON results retrieved. These parameters vary depending on the data supplier used. Each parameter is a key-value pair. For Matomo, at least the See the Matomo API documentation (https://developer.matomo.org/api-reference/reporting-api#API) to find valid parameters for Matomo. For example, the Matomo example above retrieves JSON format data using the Matomo UserCountry API. |
Depending on your requirements, you can configure a file-based data supplier using the class FileBasedDataSupplier to fetch data from a JSON file.
For example:
dataSuppliers: treeMapDataSupplier: class: info.magnolia.analytics.datasource.FileBasedDataSupplier filePath: /info/magnolia/analytics/samples/json/treemap/treemap-data.json
In our demo dashboard, we show an example of search data taken from the Magnolia find bar data using a custom data supplier with a limit on the number of results returned:
dataSuppliers: periscopeDataSupplier: class: info.magnolia.analytics.datasource.PeriscopeDataSupplier limit: 8 # limit the number of results from the supplier
Class: PeriscopeDataSupplier
Again in our demo dashboard, we show an example of Magnolia content tags data using a custom data supplier:
dataSuppliers: contentTagsDataSupplier: class: info.magnolia.analytics.datasource.ContentTagsDataSupplier
Class: ContentTagsDataSupplier
You configure what content and how it is displayed in your dashboard in the chart definition YAML file under
chartDefinitions
.
The magnolia-analytics-amcharts-ui
submodule provides several predefined amCharts charts under /analytics-ui/chartTypes
:
You can see details of the amCharts chart types in their documentation.
You can reuse the predefined chart types when defining your chart definition using YAML includes and decorating the series
provided.
chartDefinitions: line2GA: class: info.magnolia.analytics.amcharts.data.AmChartDefinition label: Session by date from GA chartType: !include:/analytics-ui/chartTypes/column-and-bar/simple-column.yaml # This is example how to decorate chart type to decorate data field mapping series: - name: series dataFields: - name: categoryX jsonPath: $.reports[*].data.rows[*].dimensions[*] # Decorate jsonPath for categoryX to map data from GA - name: valueY jsonPath: $.reports[*].data.rows[*].metrics[*].values[*] # Decorate jsonPath for categoryX to map data from GA dataSupplier: googleSupplier
chartDefinitions: column2Matomo: label: User country from Matomo class: info.magnolia.analytics.amcharts.data.AmChartDefinition chartType: !include:/analytics-ui/chartTypes/pie-and-donut-group/pie.yaml responsive: enabled: true dataSupplier: matomoSupplier
In this example, the predefined pie.yaml
chart does not show a decorated series because Matomo can reuse the default series directly.
If you do not want to use a predefined chart type supplied by Magnolia, you can configure your own. There are two ways of doing so:
Select the amCharts type you require and provide the native JSON-based config by amCharts.
For example:
chartDefinitions: treemap: label: treemap class: info.magnolia.analytics.amcharts.data.AmChartDefinition dataSupplier: treeMapDataSupplier nativeJsonConfig: /info/magnolia/analytics/samples/json/treemap/treemap-config.json type: TreeMap
Write your own chart type YAML configuration.
For example:
class: info.magnolia.analytics.amcharts.data.configuration.AmChartType type: PieChart series: - name: series type: PieSeries dataFields: - name: category value: label jsonPath: $.[*].label - name: value value: nb_visits jsonPath: $.[*].nb_visits legend: position: bottom
And include it in your chart definition:
chart-2: dataSupplier: mostActiveUsersDataSupplier label: Most active users by publication class: info.magnolia.analytics.amcharts.data.AmChartDefinition chartType: !include:/analytics-ui/chartTypes/pie-and-donut-group/pie.yaml
| required |
| required A name for the given chart displayed in the dashboard. For example |
| required The source of the data displayed in the charts. For example, |
| required A text label displayed as the title of the chart in the dashboard. For example "Session by date from GA". |
| required Chart definition class: AmChartDefinition |
| required if you are using a predefined chart type Use a Magnolia-specific directive YAML include to reuse the predefined chart types delivered by the For example: chartType: !include:/analytics-ui/chartTypes/pie-and-donut-group/pie.yaml You then override the chart type series to adjust the data to your requirements. |
| required Chart type class:AmChartType |
| required Each chart type can support only relevant amCharts series. When using a predefined chart type, the correct series is included. You must override the series to adjust the data to your requirements.
Many amCharts series settings are available. |
| required Defines the connection between data item and actual properties in raw data. The |
| required The name of the data field. |
| required The value of the data field. |
| optional The JSONPath expression filters the data you retrieve about your site from the data supplier. The syntax you use depends on your data and what you want to display in your chart. Tips If you use a Google Analytics data supplier, you must have a valid Google Analytics access token to be able run API requests. Get one here. Copy your JSON output to https://jsonformatter.curiousconcept.com/ to format it if required. Copy your JSON output again to https://jsonpath.com/ to test out your JSONPath syntax for the Example: jsonPath: $.reports[*].data.rows[*].dimensions[*] |
| required for most chart types Defines the X axis data and appearance. For example, in the predefined simple-bar.yaml chart type: xAxes: - name: xaxe type: VALUE_AXIS See the amCharts documentation about Axes. |
| required for most chart types Defines the Y axis data and appearance. For example, in the predefined simple-bar.yaml chart type: yAxes: - name: yaxe type: CATEGORY_AXIS renderer: minGridDistance: 10 grid: location: 0 dataFields: category: city_name See the amCharts documentation about Axes. |
| required If you are not using a predefined chart type Path to the native JSON-based config custom configuration you created. For example: chartDefinitions: treemap: label: treemap class: info.magnolia.analytics.amcharts.data.AmChartDefinition dataSupplier: treeMapDataSupplier nativeJsonConfig: /info/magnolia/analytics/samples/json/treemap/treemap-config.json type: TreeMap |
| required If you are not using a predefined chart type The chart type for the native JSON-based config custom configuration you created. For example: |
| required if you override the default dashboard dimensions Defines where the chart is positioned in the dashboard. Values can be: You can override the default by configuring specific dashboard dimensions. If you do so, you must specify compatible positions for your charts. (By default, the dashboard has two columns. Charts are positioned automatically on a first come, first served basis in the columns from left to right on as many rows as are necessary for the number of charts you add.) |
The dashboard dimensions define how many rows and columns are in your dashboard.
By default, the dashboard has two columns. Charts are positioned automatically on a first come, first served basis in the columns from left to right on as many rows as are necessary for the number of charts you add.
You can override the default by configuring specific dashboard dimensions.
We recommend you only override the default if you need to customize positions for a specific purpose. Note that the dashboard dimensions and the chart positions are related to each other and if they are not correctly configured together, they may cause errors. For example, if the dashboard dimension is configured to 2x2 but a chart is configured to position 3 an error will occur.
This example shows the configuration for a dashboard with 2 rows and 6 columns:
dimension: rows: 2 columns: 6
You can also define a specific position for each chart type you define if you choose. For example:
.... position: row: 1 column: 3 rowSpan: 1 colSpan: 3
Note that the first row and column are counted as 0
. The configuration above places the chart in the green squares:
0 0 | 1 | 2 | 3 | 4 | 5 |
1 |
Developers can define filters to drill down into the data displayed in the charts that are configured. When set, each filter is applied to all the charts in the dashboard simultaneously. For example, if you set a filter to display a given time range, all the charts display data for that time range.You can use basic Magnolia field types to define filters, such as date, rich text, and so on.
Complex fields such as multiValue, composite, switchable and collapsibleComposite are not supported.
Example
filterFields: - name: idSite class: info.magnolia.ui.form.field.definition.TextFieldDefinition placeholder: site id label: Site ID - name: filter_limit class: info.magnolia.ui.form.field.definition.TextFieldDefinition label: Filter limit - name: date class: info.magnolia.ui.form.field.definition.DateFieldDefinition label: Date - name: startDate class: info.magnolia.ui.form.field.definition.DateFieldDefinition label: Start date - name: endDate class: info.magnolia.ui.form.field.definition.DateFieldDefinition label: End date
| required |
| required The filter names are used to append the REST call against the supplier. Therefore the value here must have a counterpart in the given data suppliers. You can also use filters to override parameters. Matomo values: https://developer.matomo.org/api-reference/reporting-api#API Google values: https://developers.google.com/analytics/devguides/reporting/core/dimsmets |
| required Fully qualified classname for the field. See List of fields. For example: DateFieldDefinition |
| required A text label displayed as the title of the filter in the dashboard. For example "Start date". |
| optional Text to be displayed in the filter field when you do not want the filter to appear empty. |
| optional Options to be applied to the filter contents. The sub-properties depend on the field type being used. |
You can change the CSS and theme of the dashboard charts to suit your visual requirements.
To do so, update the amcharts.css
and amcharts_theme.js
files in /info/magnolia/analytics/amcharts/vaadin
.
Magnolia supports amCharts responsiveness feature.
To make your charts responsive, enable the feature by adding the responsive
property to the chart definition and setting it to enabled: true
as shown in this example:
chartDefinitions: column2Matomo: label: User country from Matomo class: info.magnolia.analytics.amcharts.data.AmChartDefinition chartType: !include:/analytics-ui/chartTypes/pie-and-donut-group/pie.yaml responsive: enabled: true dataSupplier: demoMatomoSupplier
If you enable responsiveness, when a chart’s pixelWidth is <= 500px, Magnolia automatically hides the chart legend.
You can change the responsive rules in /info/magnolia/analytics/amcharts/vaadin/amcharts_connector.js
.
You can configure the cache in the JCR or the File System (YAML) under: /analytics/config.yaml
By default, the cache is enabled and content pulled from your external solution is updated every 300 seconds (5 minutes).
cachingDefinition: enabled: true invalidateInSeconds: 300
Set the property to false
to disable caching.
When you click the refresh button on the dashboard, the cache is invalidated.