Probabilistic Revenue Sharing
More often than not, high quality content involves more than one person. So, how do you share a portion of your revenue if you only have a single link
tag with a payment pointer?
One way is through probabilistic revenue sharing (revshare). In Web Monetization, probabilistic revenue sharing works by randomly choosing from a list of predefined payment pointers each time a web monetized visitor loads your page. The visitor pays to the chosen pointer until the page is reloaded or closed.
The chance of a payment pointer being chosen is based on its assigned weight. For example, if Alice's payment pointer has a weight of 50, the pointer has a 50% chance of being chosen. The laws of probability state that Alice’s share will approach 50% of the page’s total revenue as more users visit the site.
A basic example
This example shows how to define a list of payment pointers and assign each pointer a weight. The easiest way to establish weight is by assigning values that add to 100.
Code
<head>
<script>
// Define your revenue share here.
// If these weights add to 100 then they represent the percent each pointer gets.
const pointers = {
'$alice.example': 50,
'$bob.example': 40,
'$connie.example': 9.5,
'$dave.example': 0.5,
}
function pickPointer() {
const sum = Object.values(pointers).reduce((sum, weight) => sum + weight, 0)
let choice = Math.random() * sum
for (const pointer in pointers) {
const weight = pointers[pointer]
if ((choice -= weight) <= 0) {
return pointer
}
}
}
window.addEventListener('load', () => {
const monetizationTag = document.createElement('link')
monetizationTag.rel = 'monetization'
monetizationTag.href = pickPointer()
document.head.appendChild(monetizationTag)
})
</script>
</head>
How does it work?
First, we define the payment pointers and assign each one a weight. If the weights total 100, then they represent the percentage each pointer gets.
const pointers = {
'$alice.example': 50,
'$bob.example': 40,
'$connie.example': 9.5,
'$dave.example': 0.5,
}
Next, we define how a payment pointer is chosen.
function pickPointer() {
const sum = Object.values(pointers).reduce((sum, weight) => sum + weight, 0)
let choice = Math.random() * sum
for (const pointer in pointers) {
const weight = pointers[pointer]
if ((choice -= weight) <= 0) {
return pointer
}
}
}
Finally, we add the code that dynamically inserts the randomly chosen payment pointer into the page on each load/refresh.
window.addEventListener('load', () => {
const monetizationTag = document.createElement('link')
monetizationTag.rel = 'monetization'
monetizationTag.href = pickPointer()
document.head.appendChild(monetizationTag)
})
Interactive example
This example shows how the random choices will approach the correct percentages over enough tries. You can customize the number of times to randomly choose a pointer and it will show you the results. The example doesn't require you to have Web Monetization enabled in your browser. No real payments are occurring.
If you see the source files instead of the example, click View App in the bottom right.