How to work with customer merging

Data can come from CRM, websites, mobile applications, call centers, stores. CDP detects duplicates and merges records about the same customer into a single profile.

To calculate, for example, the average revenue per paying customer for a period, you need to take the revenue for the period and divide it by the number of unique customers with an order.

What to do if a customer made one order from a phone, and another a couple of days later from a tablet?

Maestra will merge such customers into one, but in the exported data on customer orders, the orders will be linked to different customer IDs.

To get the latest current customer ID in an order, you need to link the orders table (Orders) to the customer merging table (MergedCustomers) by the unmergedCustomerId key.

As a result, you should get something like this code:

SELECT 
COALESCE ( mc.mergedCustomerId, o.unmergedCustomerId ) AS customerId,
*
FROM 
Orders o
LEFT JOIN MergedCustomers mc ON mc.unmergedCustomerId = o.unmergedCustomerId