The MKTATTRIBUTION Procedure

Examples: MKTATTRIBUTION Procedure

This section provides an example of the model that the MKTATTRIBUTION procedure supports.

The following statements read a data table that contains records of 2 million customer visits. The table has four columns: sec is the number to identify the customers, time is the time when the customer visits, c is a nonnegative integer variable that is converted from the channel variable and is to be used in the model, and channel is the channel that the customer visits at time t.

data marketData;
   format time DATETIME.;
   input sec  time:ANYDTDTM40.  c channel & $ 15.  ;
datalines ;
1   24MAY18:00:00:00    1   Direct Mail
1   05JUN18:23:25:55    4   email
1   05JUN18:23:26:36    0   conversion
2   13JUN19:18:05:25    11  social
2   26OCT19:03:44:08    4   email
3   22AUG19:13:25:49    7   paid social
4   28JUL19:00:52:21    7   paid social

   ... more lines ...   

1169566 15JUN18:11:18:33    5   organic
1169567 05MAY18:00:00:00    1   Direct Mail
1169567 03APR20:05:40:37    5   organic
1169567 03APR20:12:02:20    0   conversion
1169568 07SEP19:21:50:07    7   paid social
1169569 04MAY19:15:44:22    5   organic
1169570 14AUG18:15:14:56    11  social
1169570 21OCT19:00:00:00    1   Direct Mail
1169571 15MAY19:19:32:36    7   paid social
;

The following statements create the table (Figure 13) to show the one-to-one relationship of channel to c:

data channel;
  set marketData(keep=c channel);
run;
proc sort data=channel
  dupout=channel_NoDupkey nodupkey;
  by c;
run;
proc print data=channel noobs; var c channel; run;

Figure 13: Market Channels

cchannel
0conversion
1Direct Mail
2app
3display
4email
5organic
6paid search
7paid social
8phone
9print
10sms
11social
12video
13web


In addition to the conversion, which equals 0, in the c variable, there are 13 distinctive channels shown in Figure 13.

The following statements estimate the Markov attribution model that has 13 channels:

proc sort data=marketData out=marketData nodupkey;
   by sec time;
run;
data mycas.marketData2;
   set marketData;
run;
proc mktattribution data=mycas.marketData2;
   id section=sec time=time;
   model c / nchannel=13;
   output outremoval=mycas.rm outcontribution=mycas.contribution outtpm=mycas.tpm ;
run;

The model information and number of observations are shown in Figure 14.

Figure 14: Model Information and Number of Observations

The MKTATTRIBUTION Procedure

Model Information
Model TypeMarkov Attribution
Number of Channels13

Number of Observations2045016
Number of Missing Observations0


The estimates of the initial state probability vector are shown in Figure 15.

Figure 15: Estimates of Initial State Probability Vector

Initial State Probability
Vector
StateEstimate
Channel 10.20354
Channel 20.00003
Channel 30.00706
Channel 40.10067
Channel 50.20121
Channel 60.04194
Channel 70.34759
Channel 80.00027
Channel 90.00159
Channel 100.00141
Channel 110.07281
Channel 120.00330
Channel 130.01859
Conversion0.00000
Null0.00000


The estimated transition probability matrix are shown in Figure 16.

Figure 16: Estimated Transition Probability Matrix

Estimated Transition Probability Matrix
StateChannel 1Channel 2Channel 3Channel 4Channel 5Channel 6Channel 7Channel 8Channel 9Channel 10Channel 11Channel 12Channel 13ConversionNull
Channel 10.000000.000020.008960.349960.230780.073110.028760.000830.014990.004410.007600.001120.010820.009200.25946
Channel 20.080460.000000.000000.126440.459770.011490.000000.000000.000000.022990.000000.000000.011490.126440.16092
Channel 30.221100.000050.000000.154650.128130.023830.015920.000000.000700.001540.004230.000350.004730.044320.40047
Channel 40.376180.000040.009180.000000.206140.010100.001760.000010.000380.003210.002170.000160.004880.066170.31964
Channel 50.209060.000060.007760.197830.000000.023270.004320.000790.002840.002520.009880.000530.013390.185440.34231
Channel 60.067610.000040.006800.038760.205020.000000.003800.000140.002360.000430.001920.000680.010790.532860.12880
Channel 70.043910.000000.003720.014890.029800.001880.000000.000000.000020.000410.015130.000040.000430.017310.87246
Channel 80.037180.000000.000000.004890.297460.004890.000000.000000.000000.000000.000000.012720.003910.637960.00098
Channel 90.039070.000000.001080.012860.171870.021500.000490.000000.000000.000200.001180.000100.009820.720060.02179
Channel 100.273630.000170.006700.152310.238270.010390.003180.000000.000340.000000.001340.000170.004190.080430.22889
Channel 110.087230.000000.003740.025870.067700.002750.027860.000010.000150.000370.000000.000020.001800.026220.75627
Channel 120.035820.000000.003610.019470.121880.018030.002640.005050.000960.000480.000480.000000.005050.718750.06779
Channel 130.053140.000120.002580.070750.266520.019660.002550.000060.003170.001770.004940.001120.000000.202510.37110
Conversion0.000000.000000.000000.000000.000000.000000.000000.000000.000000.000000.000000.000000.000001.000000.00000
Null0.000000.000000.000000.000000.000000.000000.000000.000000.000000.000000.000000.000000.000000.000001.00000


The conversion rates are shown in Figure 17.

Figure 17: Conversion Rates

Conversion Rates
MethodRate
Data Based0.18771
Markov Chain0.18771


The removal effects are shown in Figure 18.

Figure 18: Removal Effects

Removal Effects
ChannelEffect
10.07980
20.00003
30.00379
40.06379
50.11014
60.05682
70.01567
80.00079
90.00833
100.00157
110.00668
120.00335
130.01071


The removal effect of a channel is the decrease in the probability of overall conversion if the channel were removed. In Figure 18, you see that channel 5 (organic) leads to the greatest decrease in the probability of conversion if it is missing.

The contributions are just normalized removal effects to indicate each channel’s contribution to the conversion. The contributions of the Markov attribution model and the other three heuristic attribution models are shown side by side in Figure 19. The last-touch model does not place as much value on channel 1 (direct mail) as other methods do, but it attributes the most value to channel 5 (organic). The first-touch model does not value channel 4 (email) as much as other methods do, but it attributes the most value to channel 1 (direct mail). The Markov and linear attribution models have similar attribution values for most of the channels, except that there is a 9% difference between the two models on the contribution of channel 1 (direct mail). The position-based model and time-decay model both attribute less credit to channel 4 (email), which is the third most important channel according to the Markov model. The reason might be that the email channel always appears in the middle of the customer journey.

Figure 19: Channel Contributions

Channel Contributions
ChannelMarkov ChainFirst TouchLast TouchLinearPosition
Based
Time Decay
10.220780.472480.023200.234930.241790.23236
20.000080.000030.000060.000050.000050.00005
30.010490.002380.004860.004420.003930.00408
40.176490.034890.130810.084450.083690.08707
50.304700.247070.433120.344350.341270.34541
60.157190.158310.263820.215580.213760.21484
70.043360.027740.033850.031060.030940.03090
80.002170.001360.003560.002550.002510.00258
90.023040.007140.040010.024370.024050.02434
100.004340.000920.002620.001760.001770.00188
110.018470.011940.012230.012370.012220.01219
120.009260.014080.016310.015150.015170.01521
130.029640.021660.035560.028970.028840.02908


Last updated: September 15, 2022