Introduction
A distinguishing feature of Oplon Analytics is the presence of configurable modules called Adapters, which allow customization of data flow and facilitate routing to external services, including the popular Matomo. Integration with Matomo is facilitated by the flexibility of Adapters, which allow users to easily adapt configurations according to specific needs. This approach simplifies the connection process between Oplon Analytics and Matomo, ensuring reliable and secure data transmission. In summary, Oplon not only provides a robust data management platform, but also offers the ability to extend its functionality through integration with third-party services such as Matomo, making data analytics even more powerful and adaptable to business needs.
Flow
The analytics generation flow is divided into two parts. The first part intercepts everything that happens on the client side and saves it to the DB. The second part takes the data from the DB, transforms it and sends it to Matomo.
Data Collection
The first part follows the following flow:
- the client requests a web page;
- the ADC forwards the request to the backend;
- the backend returns the requested HTML page;
- the rewrite body rule is triggered, which injects a JavaScript into the header tag of the HTML;
- the client receives the HTML page with the injected JavaScript;
- when it triggers an event of any kind on the page, for example a click, the JavaScript intercepts the event and sends the information to the ADC;
- the ADC receives the client event info and processes it;
- while the data is being processed, the client is answered that the data was received correctly;
- once the data has been fully processed, it is written to the DB.
Sending data to Matomo
The second part:
- the WebCache module closes a partition of the DB (see the webcache section for partition closure settings);
- the DB responds that it has successfully closed the partition;
- the WebCache module sends to the ETL module that the partition has been closed;
- the ETL module asks the DB for all the data for that partition;
- the DB responds with the requested data;
- the ETL module processes and transforms the data into a JSON format compatible with the Matomo API;
- the ETL module sends the data to Matomo;
- Matomo responds saying that the data has been received.
Oplon Secure Access node
First, it is necessary to configure the nodes that deliver the services (OSA nodes), so that they capture data while browsing and send it to the Analytics node.
Import file
Having purchased the Analytics license you will come into possession of 3 files that you need to upload inside the interface that resides in Files->Rewrite classes.
The files are:
- oplon-anlytics.js: JavaScript injected into the head tag of the HTML;
- LBLHTTPAnalyticsCollector.java: rewrite header rule that intercepts client events and sends them to the DB;
- LBLHTTPAnalyticsBody.java: rewrite body rule that injects the JavaScript into the head tag of the HTML.
Creating Rewrite Rules.
From the left menu go to ADC Settings > Rewrite Management > Rewrite Header rules, create a new rule calling it oplonAnalyticsCollector
and set the flow to REQUEST
.
Click on the edit button to edit the rule, open the Rewrite header rule panel and value the httpInterceptorClass parameter with rewriteclasses.LBLHTTPAnalyticsCollector
.
From the left menu go to ADC Settings > Rewrite Management > Rewrite Body rules, create a new rule calling it oplonAnalyticsInjector
and set the flow to RESPONSE
.
Click the edit button to edit the rule, open the Rewrite body rule panel and value the httpInterceptorClass parameter with rewriteclasses.LBLHTTPAnalyticsBody
.
Open the Mime Type panel and value Mime type with text/html
, fragment Open text with <
, fragment Close text with >
.
Open the Variables panel and add two variables:
- set name with
RESOURCE_DIR
and value withinterceptors/rewriteclasses
; - set name with
FILE_NAME
and value withoplon-analytics.js
;
Adding rules
Applying rewrite rules
We now apply the Rewrite rules we just created. We can do this at any level, that is, either at the ADC level (so globally for all configured services), or on individual domains or groups of domains.
Add a rewrite header rule called disableCompressionToRewriteBody before of the oplonAnalyticsCollector rule. This allows the rewrite body rule to properly read the response HTML to inject the JavaScript.
Oplon Analytics node
Configuring module A05_LBLGoStatisticsWebCache
Now you need to configure the Aggregators on the A05_LBLGoStatisticsWebCache module. On the Oplon Analytics node go to Modules > Statistic brokers and click on the edit button of the module that is running. Open the Webcache tables parameters panel and set the partition closure values for the tables:
- L7_HTTP_HTTPS: table containing file download data;
- OA_PERFORMANCE: table that contains the performance data of pages viewed by the user;
- OA_INTERACTION: table containing all operations done by the user on the pages (client events);
- OA_ERROR: table that contains the javascript-side errors of the pages.
To set the partition closure values, you can use:
- partitionMaxRows: indicates the number of rows the table must reach before closing a partition;
- partitionMaxSeconds: indicates how many seconds the partition closes.
If both are set, the partition is closed at the first setting reached (seconds or number of rows).
Retention days indicates how many days the data is retained before it is deleted.
Open the TM aggregators panel and add four aggregators:
aggregatorID | description | tableName | execOrder | aggregatorClass |
---|---|---|---|---|
MATOMO_L7 | matomo download | L7_HTTP_HTTPS | 1 | dwhInterceptors.LBLDBAggregatorMatomo |
MATOMO_PERF | matomo performance | OA_PERFORMANCE | 1 | dwhInterceptors.LBLDBAggregatorMatomo |
MATOMO_INT | matomo interaction | OA_INTERACTION | 1 | dwhInterceptors.LBLDBAggregatorMatomo |
MATOMO_ERR | matomo error | OA_ERROR | 1 | dwhInterceptors.LBLDBAggregatorMatomo |
Go to the details of each aggregator, open the Aggregator variables panel and add on all the following values:
- name = ETL_URL;
- value = https://IP_OPLON_ANALYTICS:3333/etl (replace IP_OPLON_ANALYTICS with the ip of the Oplon Analytics machine).
Configure module E10_Analytics_ETL
Now we need to configure the ETL module so that it can request data from DB and send it to Matomo. To do this, you need to go to Modules > ETL Analytics and edit the module (which must be running) of the Oplon Analytics node. Open the Etl params panel and enter the same DB connection data that is entered in the A05_LBLGoStatisticWebCache module of the Webcache basic parameters panel.
Having reached this point, you need to access Matome and add the domains you want to monitor.
With that done, return to the ETL form, open the Matomo configuration panel, add the domain data and the Matomo API URL:
- Site name: site name (can be anything);
- Server: Matomo machine name (see Automation);
- Matomo URL: API of Matomo, e.g.: http://IP_MATOMO/matomo.php (replace IP_MATOMO with the ip of the Matomo machine);
- Token auth: generated by Matomo, must be pasted here. It is used by ETL as a password to authenticate requests to Matomo;
- Site ID: generated by Matomo when adding a domain, must be pasted here. It is sent from ETL to Matomo;
- Domain regex: regular expression that must represent the list of domains that belong to the same Site ID in Matomo. If the Site ID in Matomo contains only one domain, you can value this field with the domain;
- URI path: if you want to monitor only a specific path in the domain;
- Tags: label that logically groups domains (useful for cost centers).
Going into detail, one will also be able to set:
- Exclude Path regex: regular expression to exclude paths from statistics;
- Include RespCode: response codes of http client requests to be included in statistics (default 200).
Automation
If you want to automatically add domains to be monitored, from the left menu go to Analytics > ETL.
In the Servers panel, you will be able to add a list of Matomo machines and run the automation functionality.
There are 3 parameters:
- Server name: machine name;
- Matomo URL: URL of the Matomo API, see Matomo URL;
- Token auth: password to authenticate requests to Matomo, see Token auth.
The button with the phone icon opens the automation wizard. The first step will show all domains that have been accessed at least once after configuring routing (listener, group, domain, endpoint) but have not yet been added as domains to be monitored (see Matomo configuration panel). Checking the View ETL domains checkbox will also show domains that have already been added as domains to be monitored. Then select the domains you want to add to monitoring and click on the Next button. From here, add the Site name and possibly a URI path; then click on the Add to Matomo button.
At this point, the ETL module will contact Matomo at the address configured in Matomo URL and if it receives confirmation of addition, a new row will appear in the Matomo Configuration panel containing the info of the domain you just added.