We’ve migrated our documentation to a new site, which means some URLs have changed.
Subscriptions

Sending Propensity Scores to 3rd Party Systems

Propensity scores predicted by Piano's Likelihood to Subscribe, Likelihood to Register, Likelihood to Return, Content Likelihood to Convert, Likelihood to Cancel, and Dynamic Paywall models can be passed to 3rd party systems for analysis or targeting.

The recommended approach to do so is to add a callback method to the Composer execute call. Here's the relevant documentation page on how Composer callbacks work in general.

Callback Object

To extract the propensity scores of the user, you can add an experienceExecute handler to the tp object. The experienceExecute event will be called once all experiences have finished executing, so you don't have to worry about the callback running more than once in a pageview. Here is the code you can use:

tp.push(["addHandler", "experienceExecute", function (data) { console.log(data.result.events[0].eventExecutionContext.userSegments.COMPOSER1X.segments); // This will return an array with all scores }]);

The callback will return a object, which contains a lot of information about the user's experiences, segmentation, and scoring that happened for this user. Inside this object, you can find the user's propensity scores.

The callback will return a data object, and the code snippet above shows how to locate the propensity scores within that object and print them to the browser console. The list of scores will look like the following example, with the exact entries included depending on which propensity models are actively scoring users on your site:

"CScore:12345abcdef:9"
"LTc:12345abcdef:no_score"
"LTreturn:12345abcdef:1"
"LTs:12345abcdef:2"

When splitting each string by ":", you'll get the name of the propensity model as the first element and the score of the user as the third element. The second element, here shown as "12345abcdef" for illustrative purposes, is an internal Piano model identifier which is static per site and can be ignored.

The specific part of the response object that contains propensity scores looks like this in the Chrome console:

LtS.png

The JSON path to this list of scores is: data.result.events[0].eventExecutionContext.userSegments.COMPOSER1X.segments

Even though the data.result.events list often has multiple entries, it does not matter which one you look at. All of them contain the same list of scores.

Explanation of "segments" List

The Likelihood to Subscribe score in the screenshot above is the segment list entry that starts with LTs and ends with 6. This means the Likelihood to Subscribe score for this user was 6 at this time, on a range from 0 to 9 where 9 is the highest likelihood. These scores can also be seen as buckets of propensity where each value corresponds to a bucket of size 10%. 0 means the propensity is between 0% and 9%, 1 means 10-19%, etc.

The long string in-between the first and second colon can be ignored, as that is an internal identifier in the Piano backend and not relevant in the context of external data passage.

The list of segments can have zero, one entry, or more than one entry. In the screenshot above there are two entries, containing the propensity score for this user for the Likelihood to Subscribe model and another for the Likelihood to Return model. The type of propensity score is determined by the string before the first colon, here LTs and LTreturn.

Other values than these two are also possible, depending on the features that have been enabled in Composer. For example, when in use, Piano's content propensity algorithm is shown as CScore and the Dynamic Paywall model is defined as RevenueOpt.

On "no_score" and Empty Score List

One important thing to note about parsing scores like this is that there won't necessarily be a score for a given model for a user. Piano does not provide a Likelihood to Subscribe score on the first pageview of a new user that has not been seen on this site before. In that case, the string no_score will be in the segments list instead of the numerical score, like this:

LtS1.png

In case the segment list is empty, it's safe to assume that the user has no_score. When passing the value on to 3rd party systems we recommend passing no_score in both these cases (no_score result and empty result) as there is no need to distinguish between the two.

Alternate Method to Access Scores

If you would like to grab all of these scores directly from the console, you can also use this snippet to get the same result:

tp.experience._getLastExecutionResult().result.events[0].eventExecutionContext.userSegments.COMPOSER1X.segments

Disclaimer

Integrating into this response object is considered a deep technical integration. As of the writing of this documentation, there are no plans to change these callbacks, but it is possible Piano will need to make changes to the Composer script in the future that will require changes to this configuration. While Piano strives to inform clients of any such changes, as an additional safeguard Piano recommends that clients using this method add the necessary monitoring of the number of scores fetched using this approach, and getting in touch with their Account Manager if that number were to drop to zero.

Last updated: