Shapley Value regression (Game Theory) as an Attribution solution

Shapley Value regression (referred to commonly as Game Theory) is at its core quite an elegant solution, and one I’ve left until quite late on in the series to post about as it is an approach I haven’t implemented, despite understanding its principles.

[ I therefore offer no real practicable insight, short of that from discussions with 3rd party practitioners and published papers. ]


At the core of this algorithm sits a fairly simple two stage approach

1              Identify a baseline ‘importance’ value for each campaign that represents the expected conversion performance (number of conversions, or anticipated conversion rate)

2              Run a series of regressions comparing the importance value of each campaign in turn with each of the others as a pair, triplet, or higher order combination. Allocate the conversions observed when these combinations occur in the attribution data based on the Shapley Value regression approach


In essence, the approach simulates a series of multivariate (A/B) test uplift comparisons. I first came across this approach when assisting in pilot testing with GoogleNY shortly after their acquisition of Adometry. At the time I little understood the approach, focusing more on the credibility of the attributed outputs.

I came across it again when research uncovered the Shao and Li paper “Data-driven Multi-touch Attribution Models”, which details a 2nd order Shapley regression almost as an aside to their ensemble logistic regression approach (the latter of which, frustratingly, I cannot get to produce valid results using our data!).

A more comprehensive step by step detailing of the technique is incorporated in to the Abakus patent ( Incidentally, Abakus provide a series of short videos on their site explaining how the technique is applied, though the algorithm (as far as I could see) isn’t covered.


Hence, a simplified example of how stage 1 and 2 are executed (as I understand it). Note that the below approach is based upon the Abakus method described in their patent, but other methods for determining the stage 1 ‘player values’ are alluded to, if not detailed, in other articles (  such as logistic regression, time-decay based models, etc.


Imagine this core result set obtained from a hypothetical attribution data set:

S1 S2 S3 Desc Unique Users Conversions cr%
PPC Brand p1 800 60 7.500%
SEO p2 850 45 5.294%
Display p3 150000 10 0.007%
PPC Brand SEO p1,2 300 25 8.333%
PPC Brand Display p1,3 1800 65 3.611%
SEO Display p2,3 1900 55 2.895%
PPC Brand SEO Display p1,2,3 700 40 5.714%
P p0 3000000 100 0.003%



From this aggregated data set, we ascertain each campaigns ‘playing value’ – i.e. stage 1 above. Starting with PPC Brand, we multiply its conversion rate in isolation (7.5%) against all the combinations in which it appears (800+300+1800+700) and add to that the rate that would occur anyway (the baseline of 0.003% against 850+150000+1900+3000000). This gives a playing value for V1  (PPC Brand only) of 375. This is repeated for each of the single campaign only combinations (V2 and V3).

For the two-campaign sets, the channels base conversion rate is applied against the combinations it occurs in but which the OTHER campaign does not, PLUS how it performs together. So for PPC+SEO, then this set (V1,V2) is worth =

7.5% * (800+1800)                           (the PPC component of the set)

+ 5.294% * (850+1900)                   (the SEO component of the set)

+8.333% * (300+700)                      (the combined PPC+SEO components)

+0.003% * (150000+3000000)      (the baseline * what’s left)

= 529


The last remaining combination of all sets (V1,V2,V3) is effectively the ‘game’ total – a sum of all conversions (400).  Then we account for the base line set, V0 (no media) which is 105 (0.0003% * all users).

This yields a ‘game’ as follows against which we enter each ‘campaign value’ in the order seen (starting with the special value, V0 = 105). On adding each subsequent set, we evaluate the ‘incremental’ difference.

E.g. in the first combination, PPC Brand, we know its V1 score is 375. Therefore after V0 has claimed 105, only 270 is left.

In the second combination, PPC Brand+SEO, we apply 105, then 270, then 529-270-105 = 154

And so on as follows:


Marginal Improvement Values
Step 1 Step 2 Step 3 V0 (Base) PPC Brand SEO Display
PPC Brand 105 270
PPC Brand SEO 105 270 154
PPC Brand Display 105 270 -92
PPC Brand SEO Display 105 270 154 -129
PPC Brand Display SEO 105 270 117 -92
SEO 105 198
SEO PPC Brand 105 225 198
SEO Display 105 198 -57
SEO PPC Brand Display 105 225 198 -129
SEO Display PPC Brand 105 154 198 -57
Display 105 5
Display PPC Brand 105 173 5
Display SEO 105 136 5
Display PPC Brand SEO 105 173 117 5
Display SEO PPC Brand 105 154 136 5
Attribution: 105 223 164 5
Target is 400 conversions: 105 167.7 123.5 3.9


The attribution score is the average contribution of the column which typically may exceed the actual number of conversions, and hence is scaled to a target number of conversions.


The occurrence of negative values occurs because while the model is based on cooperative game theory (that is, the worth from a combination of participants’ activity cannot be worse than the best ‘player’ alone) in reality two channels occurring together may well have a conversion rate LESS than the parts achieve “independently”. This effect is observed in the Anderl et al. result set ( Does this mean that a channel has a negative effect? Likely, no. It’s much as we observe in logistic regression where the likelihood is that two different customer states are being pooled.


Hence we again turn to data pre-processing, whereupon I can offer no real practical advice short of that recommended in the Abakus patent and elsewhere (such as Archak et al., “Mining Advertiser-specific User Behaviour Using Adfactors): pre and post site visit segmentation of data. The logic behind this is to ascertain the clicks that are most likely ‘navigational’ in nature, and thus push credit the other side of this divide in to ‘influencing’ activity.

In addition, a proportion is extracted from the influencing bracket and allocated to a baseline of non-digital media conversions. I am admittedly unclear how these proportions are decided given the exact number of non-converting, non-exposed users is not directly measurable, but trust that an estimate of cookies in market can at least give a steer. I imagine also a calibration of the outputs is enacted in order to bring the results in line with those expected (again from independent tests).


So in summary – the game theory as an approach isn’t overly complex. The difficulty though is the efficient reduction of the data in to distinct sets, and then the stepwise allocation of ‘values’ as seen in stage 1. Stage 2 as it happens has been solved in a variety of packages in R and is freely available (and is quick to execute).


If you’ve access to GA Premium, then ultimately it is a version of this approach that is deployed in the Data-Driven Algorithm available under the attribution section. It’s not easy though to determine what data manipulation has been employed (if any?) given that the algorithm is locked up in a black box click-and-go.

Even so, I find the results interesting if only for the ability to see the ‘direct conversion’ land grab. Display campaigns increase against a last click view of the world, but maybe not quite so much as we see in say the Markov approach. In addition, some non-brand PPC terms also seem to increase – the opposite from that seen in other approaches I’ve tried. This might be via collection from the direct conversion pool, but either way, it is always interesting to have another model, especially one requiring little effort from the user.


Note for reference: An independent comparison of results is available in the aforementioned Anderl paper and is well worth a read given the differences observed between models.

Markov Chain approach to digital attribution

I’ve been using a Markov Chain approach for some time now, refocusing on this approach  soon after the release of Davide Altomare’s excellent ChannelAttribution package in R back in January (’16). We’ve had a basic implementation of this method built in R for some time, but having the speed (from C libraries) and the simplicity of its front end has really allowed extensive testing of variables and input data.

Over the past few months it has been pleasing to see this approach gain wider exposure ( and ), though these working examples predominantly use data from Google Analytics which can have gaps when it comes to display impression tracking.

Rather than recite the methodology here (both the above posts cover these well, as does Davide’s original slideshare), I’d prefer to share my experience with this approach. As is the case with other attribution techniques, the model is sensitive to the data you feed in to it, and importantly I feel (so far) this hasn’t been discussed in detail.


If you are using purely path to conversion data, that is only successfully converting journeys, then you will achieve a very different result from the model than if you include non-converting journeys (and apply the var_null parameter). Principally this is because your starting and subsequent transition probabilities will vary hugely if you capture and incorporate all display impressions.

Objectively having only conversions isn’t a true representation of the underlying data, but whether or not including the non-converting data improves the results is more subjective. As mentioned in previous posts, running independent A/B uplift tests can help give a target with which to select an approach.


Secondly, changing the order of your Markov model also has a significant change on your results. If you read the paper on which the package is based (Eva Anderl et al. ) the authors settled on a third order model based on the model fit to the data, but I have read results from other sources presenting best fit with 2nd order Markov chains.

These decisions are predominantly based on a few statistical tests; how well the model predicts the original data’s successes and fails, how consistent the results are (stability), and top decile lifts. These tests are fairly arbitrary in my mind, and from a practitioner’s point of view I am more concerned with how the results match up with other, independently sourced real world results. While I can respect and appreciate that having the model replicating the structure of the data is a good thing, having result consensus with independent tests is, for me, a better indicator of ‘goodness’.

As a result, I generally work with 2o and 3o models and try and match external test results.

I think first order Markov is too simplistic, and suffers from a passive serving effect: that is, display impressions that appear in a user’s path but which likely haven’t influenced the conversion. Fourth order loses the finer detail; when the majority of conversions occur within a few steps then four-tuple sequences lose the transitional detail.

Having mentioned passive touchpoints such as impression serving (i.e. advertising that is dictated by a targeting algorithm rather than a user’s choice to interact such as that seen with a click), it is worth a further comment on this issue.

Where regression techniques pick out incremental correlation, the Markov approach rewards any touch point that occurs in a successful tuple. Our initial findings indicate that without prior distinction, display impressions in particular receive more credit than a ‘causation’ based test would suggest. Model order selection does vary this credit, but the more thorny issue of impression viewability is at issue here.

Wider reading can be found in many Media industry sites, but the quick version of this is that not all served impressions are, or can be, actually seen. Without data to ascertain the viewability of each impression, there is a danger you reward a campaign for its ability to identify warm targets rather than its ability to influence the conversion outcome.

We therefore exclude non-viewable impressions whenever we have the option to mitigate this eventuality.


Our work on this approach continues; despite some of the limitations above the results are not unreasonable when compared against a range of sense checks. A key advantage is that all channels are described in this model; though a downside remains that no offline/exogenous baseline contribution is identified.

Most interesting for us is how the contribution of display impression appears to notably increase vs. last-touch models, and we see much closer comparisons with A/B test results from this modelling approach than others we’ve deployed.

We are investigating further methods to refine the modelling approach. Redistribution of credit for single-click and direct-to-site conversions is one such idea; where driven by online activity, may we assume incomplete path data may have been a factor? If so, we have a probabilistic model already built to suggest what the previous step may have been.

There may be some merit in using VLMCs (Variable length Markov chains) rather than fixed length chains in order to accommodate the very different path lengths observed. Also, the possibility of integrating some offline touchpoints (such as a TV advert) based on time sequencing is an appealing proposal for further development.

Hopefully as adoption of this approach widens a broader set of ‘data pre-processing’ approaches will be uncovered and tested.