Dev.to WebDev πŸ›  Dev πŸ‘ 2 πŸ“– 3 min read

First-party customer data: linking website, CRM and ecommerce records

Disclosure: I work on Krenalis, a customer data platform. Anna is a fictional example; the identifiers and payload below are illustrative. A website form submission, a sales conversation and a paid order can belong to t

Disclosure: I work on Krenalis, a customer data platform. Anna is a fictional example; the identifiers and payload below are illustrative.

A website form submission, a sales conversation and a paid order can belong to the same customer journey while appearing as unrelated records. Before analysing that journey, we need to establish the connections between those records.

Consider Anna, who runs a small professional practice and is buying office accessories. She submits an enquiry through an online store, discusses her requirements with a salesperson and later places a €120 order. She chooses bank transfer, so payment is confirmed several days after her website visit.

The business wants to know which enquiries become paid orders and how long that takes. Answering those questions requires more than collecting additional page views.

The relevant records might look like this:

Source Available identifiers Recorded activity
Website visitor_id=web_7, lead_id=L42 Enquiry submitted
CRM contact_id=C17, lead_id=L42, store_customer_id=U204 Sales conversation
Ecommerce customer_id=U204, order_id=ORD900 Order placed and payment confirmed

These shared keys exist because the applications preserve them. The form generates a lead ID that reaches the CRM, and the sales workflow associates the contact with the store’s customer record. Without those steps, three unrelated identifiers do not provide enough evidence to connect Anna’s records.

Identifiers also need context: crm:204 and store:204 are different identities unless an explicit relationship connects them.

A useful data model retains the source records, the links between them and the evidence supporting each link. It also preserves event timestamps, allowing us to calculate enquiry-to-payment time without confusing the date of payment with the date the data was imported.

This can be implemented with database tables, SQL transformations or an identity resolution service. As the system grows, the important questions are how links are created, how incorrect matches are corrected and whether the customer history can be rebuilt when the rules change. Records without reliable links should remain separate.

Google Analytics 4 can receive backend events through its Measurement Protocol. However, website tracking alone does not provide the CRM conversation or payment confirmation; an integration must supply those events and the appropriate identifiers. Google’s sending-events guide.

Building the customer history and delivering an analytics event are separate responsibilities. An integration may prepare an event directly from an order record, while a warehouse process connects the wider history. Creating a unified profile does not automatically make every identifier available to the delivery process.

For Anna’s order, suppose the measurement plan defines a purchase as a confirmed payment. A corresponding GA4 request body could be:

{
  "client_id": "1234567890.1796047200",
  "events": [
    {
      "name": "purchase",
      "params": {
        "transaction_id": "ORD900",
        "currency": "EUR",
        "value": 120,
        "items": [
          {
            "item_id": "OFFICE-KIT",
            "price": 120,
            "quantity": 1
          }
        ]
      }
    }
  ]
}

For a web stream, the request also needs a measurement_id and an api_secret, which must remain confidential. The client_id should come from the corresponding website measurement and be retained through a permitted data flow; it should not be replaced with an arbitrary CRM contact ID. Measurement Protocol setup.

Send the event when payment is confirmed. If delivery is delayed, preserve its actual occurrence time within Google’s timestamp limits. A matching client ID alone does not guarantee attribution to Anna’s earlier session; session-related reporting has additional requirements. Measurement Protocol reference.

The measurement plan should also prevent checkout and payment confirmation from being counted as two separate purchases. Keep email addresses and phone numbers out of ordinary event parameters and user_id. Google’s guidance on personally identifiable information.

This payload has not been tested against a live property. Before production, use Google’s validation endpoint and verify the resulting reports: a successful HTTP response alone does not prove that an event was valid or processed. Event validation guide.

The connected source data supports questions beyond this single analytics event: which enquiries became paid orders, how long payment took and which orders followed a sales conversation. Maintaining those relationships centrally lets different analyses reuse the same joins as customer numbers and source systems grow.

Adapted from First-party data: connecting visits, purchases and CRM data to understand your customers, originally published on the Krenalis blog.

Generative AI was used to draft and edit this article.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.