Skip to content

Publishing Custom Analytics Events Data


Instead of publishing already available analytics events data, it is also possible to publish custom analytics data with the existing event schema. This guide will explain the steps required to do it.

This section will cover the steps required to create a sample and configure the created sample with WSO2 API-M.

Creating the Sample

You have to create a new Java/Maven project.

There is an already created sample and if you wish to use that sample instead of developing the sample from scratch, then you can ignore the steps of creating the sample and start from here.

This section will cover how to configure the pom.xml, class implementations and building the created sample.

Configuring pom.xml

Add the wso2-nexus repository to the pom.xml file.

        <name>WSO2 internal Repository</name>

Add dependencies,



  • The versions for {carbon.apimgt.version} and ${synapse.version} can be found in the jar versions available in the current API Manager package.

Implementing Required Class

AnalyticsCustomDataProvider Implementation Class

Custom analytics data can be added to the existing event schema with the use of a class of type AnalyticsCustomDataProvider. Therefore, it is required to implement a class from the AnalyticsCustomDataProvider interface. By overriding the getCustomProperties method it is possible to push custom analytics data.

In order to achieve this behavior, create a class implementing the AnalyticsCustomDataProvider Interface of

Implementation of this class should look something similar to this.

Build the Project

Build the project using,

    mvn clean install

Configuring the Sample

This section will cover the steps required to configure WSO2 API-M Gateway for the sample created above. The steps covered are adding the .jar file, configuring the deployment.toml file, and enabling the logs.

  1. Add the .jar file created in the target directory after building the project.

    Place the created .jar file inside the wso2am-4.2.0/repository/components/lib directory.

  2. Configure the deployment.toml file.

    Edit the configurations in the deployment.toml file located inside wso2am-4.2.0/repository/conf with the following configuration.

        enable = true
        properties."" = "<FullyQualifiedClassNameOfAnalyticsCustomDataProviderImplClass>"
        type = "elk"

This configuration will be used when engaging the custom data provider class.


Type should be given as elk as this property value is filtered out in cloud implementation.

  1. Enabling Logs

    To enable trace logs for the component:, edit file located inside wso2am-4.2.0/repository/conf directory.

    1. Add new publisher to the loggers list:
        loggers = org-wso2-analytics-publisher, ...(list of other available loggers)
    1. Add the following configurations after the loggers: = = TRACE = CARBON_TRACE_LOGFILE
  2. Now you can trigger an event and check the <WSO2AM-4.2.0-HOME>/repository/logs/wso2carbon-trace-messages.log to find the event object passed out from API Manager.

TRACE {} - [{ Cloud-Analytics-Queue-Worker-pool-2-thread-1 }] - 
 Adding event: 
         "userName":"[email protected]"