Activities analytics

Data coming into your datamart is stored in a multi-model database, optimizing it for different usages. To display performance analytics for elements like session duration, conversions, and funnel, the platform duplicates some user activities and information and optimizes them.

For that purpose, it is important that you use predefined event names and properties when possible. Custom events won't be taken into account when calculating metrics. For example, don't create order events when tracking an e-commerce site, but the predefined $transaction_confirmed event. $transaction_confirmed events are used when calculating conversions and amounts but not order events.

Here is a sample event that can be used in analytics:

{
    "$ts": 3489009384393,
    "$event_name": "$transaction_confirmed", // Conversion detected
    "$properties": {
        "$items": [
            {
                 "$id": "product_ID", // Used to filter in funnel analytics
                 "$qty": 20, // Used for conversion amounts
                 "$price": 102.8, // Used or conversion amounts
                 "$brand": "Apple" // Used to filter in funnel analytics
                 "$category1": "Category 1", // Used to filter in funnel analytics
                 "$category2": "Category 2", // Used to filter in funnel analytics
                 "$category3": "Category 3", // Used to filter in funnel analytics
                 "$category4": "Category 4" // Used to filter in funnel analytics
             },
             {
                 "$id": "product_ID2",
                 "$qty": 12,
                 "$price": 3.4,
                 "$brand": "Microsoft"
             }
        ],
        "$currency": "EUR"
    }
}

The list of predefined events that are used in analytics are as follows.

Activities analytics data retention

Activities analytics data is kept 4 month in order to optimize performances.

Transforming important events into your custom events

While it is better to use predefined events when possible, it isn't always the best solution for you. To keep having analytics correctly stored, you can transform your custom events to predefined ones.

Only events coming into the datamart after an event transformation has been defined will be transformed.

Those transformations don't transform user activities and events anywhere else. You should use activity analyzers to transform them everywhere.

Event transformations

An event transformation is linked to a datamart. Here is a sample transformation:

{
    "id": 15, // Read only
    "datamart_id": "3333", // Read only
    "created_ts": <>, // Read only
    "created_by": <>, // Read only
    "last_modified_by": <>, // Read only
    "last_modified_ts": <>, // Read only

    "channel_id": "8888",
    "source_event_name": "order",
    "target_event_name": "$transaction_confirmed",
    "mapping_id": 15
}

Property mappings

Event transformations use property mappings to choose which property in your custom event becomes which property in the predefined event.

Here is a sample property mapping to start with for $transaction_confirmed events.

// Comments are here to help you understand, 
// remove them before uploading mappings as they are not accepted in JSON
{
  "id": 17, // Read only
  "created_by": <>, // Read only
  "created_ts": <>, // Read only
  "mapping": {
    "values": [
      {
          // Maps $properties.order.order_products[] to $items[]
           "target_attribute_name": "$items",
           "source_attribute_path": {
               "attribute_name": "$properties",
               "sub_path": {
                   "attribute_name": "order",
                   "sub_path": {
                        "attribute_name": "order_products"
                   }
               }
           },
           // Alternative : mapping directly $properties if there are no multiple
           // elements in the event. It will be treated as an array of only one item
           "target_attribute_name": "$items",
           "source_attribute_path": {
                "attribute_name": "$properties"
           },
           
           // Maps $properties.order.order_products.xxx to $items.xxx
           // You can't use other target attributes than the ones 
           // in this example.
           // But they are not all mandatory : a non used target 
           // attribute will use the default value
           "children": [
               // $properties.order.order_products.product.id
               // becomes $items.$id
               // to be used by analytics database
               {
                   "target_attribute_name": "$id",
                   "source_attribute_path": {
                     "attribute_name": "product",
                     "sub_path": {
                        "attribute_name": "id"
                     }
                   }
               },
               // $properties.order.order_products.qty
               // becomes $items.$qty
               // to be used by analytics database
               {
                   "target_attribute_name": "$qty",
                   "source_attribute_path": {
                     "attribute_name": "qty"
                   }
               },
               {
                   "target_attribute_name": "$price",
                   "source_attribute_path": {
                     "attribute_name": "price"
                   }
               },
               {
                   "target_attribute_name": "$ean",
                   "source_attribute_path": {
                     "attribute_name": "ean",
                   }
               },
               {
                   "target_attribute_name": "$brand",
                   "source_attribute_path": {
                     "attribute_name": "brand",
                   }
               },
               {
                   "target_attribute_name": "$category1",
                   "source_attribute_path": {
                     "attribute_name": "cat1"
                   }
               },
               {
                   // In this example $category2 will be 
                   // event.$event_name instead of 
                   // $properties.order.order_products[].$event_name
                   // thanks to absolute_path
                   "target_attribute_name": "$category2",
                   "source_attribute_path": {
                     "absolute_path": true,
                     "attribute_name": "$event_name",
                   }
               },
               {
                   "target_attribute_name": "$category3",
                   "source_attribute_path": {
                     "attribute_name": "cat3"
                   }
               },
                {
                   "target_attribute_name": "$category4",
                   "source_attribute_path": {
                     "attribute_name": "cat4"
                   }
               }
           ]
       }
    ]
  }
}

Map events JSON as it is stored in the database and visible in user's timelines (post activity analyzers).

Get existing transformations

GET https://api.mediarithmics.com/v1/datamarts/:datamartId/analytics_event_transformation

Path Parameters

{
    "status": "ok",
    "data": [
        {
          "datamart_id": ":datamartId",
          "channel_id": "8888",
          "source_event_name": "order",
          "target_event_name": "$transaction_confirmed",
          "mapping_id": xxx
        },
        {
            ...
        }
    ]
}

Create an event transformation

POST https://api.mediarithmics.com/v1/datamarts/:datamartId/analytics_event_transformation

Path Parameters

Request Body

Update an event transformation

PUT https://api.mediarithmics.com/v1/datamarts/:datamartId/analytics_event_transformation/:transformationId

Path Parameters

Request Body

Remove an event transformation

DELETE https://api.mediarithmics.com/v1/datamarts/:datamartId/analytics_event_transformation/:transformationId

Path Parameters

Get property mappings

GET https://api.mediarithmics.com/v1/datamarts/:datamartId/analytics_mapping

Path Parameters

Create property mappings

POST https://api.mediarithmics.com/v1/datamarts/:datamartId/analytics_mapping

Path Parameters

Request Body

{
  "status": "ok",
  "data": {
      id: 17,
      created_by: <>
      ...
  }
}

Delete property mappings

DELETE https://api.mediarithmics.com/v1/datamarts/:datamartId/analytics_mapping/:mappingId

Path Parameters

{
    "status": "ok"
}

Last updated