Customer Relationship Management

part of the ArsDigita Community System by Jin Choi

The Big Picture

Publishers want to track a relationship with a customer over time by classifying them by various metrics such as site activity or buying activity. This module provides a way to specify states that a user may be in, and a way to specify state transitions based on any metric which can be expressed in SQL. This models the progression of a relationship better than a static numeric worth value. These states can then be used to target actions at particular classes of users.

An example: an e-commerce site might define the following states:

The transitions might be

Under the Hood

A user's current state and the date it was entered is stored as part of the users table:

crm_state               varchar(50) references crm_states,
crm_state_entered_date  date, -- when the current state was entered

The allowable states are listed in


create table crm_states (
        state_name      varchar(50) not null primary key,
        description     varchar(1000) not null -- for UI
);

Allowable state transitions are stored in


create table crm_state_transitions (
        state_name      not null references crm_states,
        next_state      not null references crm_states,
        triggering_order        integer not null,
        transition_condition    varchar(500) not null,
        primary key (state_name, next_state)
);
The transition_condition field specifies a SQL fragment which will get called as

update users
set user_state = **next_state**, crm_state_entered_date = sysdate
where user_state = **state_name**
and (**transition_condition**)

Periodically (as defined by the parameter UpdatePeriodHours in the [ns/server/servername/acs/crm] section and defaulting to 24 hours), each transition_condition fragment will be run as above, in the order specified by triggering_order.