Set up probabilistic revenue sharing
Esta página aún no está disponible en tu idioma.
How do you share a portion of a web monetized page’s earnings when a monetization <link>
element only supports one wallet address as its href
value?
One way is through probabilistic revenue sharing. Probabilistic revenue sharing works by choosing from a list of predefined wallet addresses each time a web monetized visitor loads the page. Payments are sent to the chosen wallet address until the visitor reloads or closes the page.
The chance of a wallet address being chosen is based on its assigned weight. For example, if Alice’s wallet address has a weight of 50 (out of 100), then her wallet address has a 50% chance of being chosen. The laws of probability state that Alice’s share of the page’s total revenue will approach 50% as more web monetized visitors access the page.
Example
This example shows how to use probabilistic revenue sharing by including a script on your web monetized page. It also uses payment pointers, but you can use any Open Payments-enabled wallet addresses.
The example below shows a list of weighted payment pointers. The easiest way to establish weight is to assign values that add up to 100.
How it works
First, we list the payment pointers and assign each one a weight.
If the combined weights equal 100, then each weight represents the percentage at which each payment pointer will be chosen. For example, $wallet.example.com/connie
has a 9.5% chance of being chosen, resulting in Connie’s share approaching 9.5% of the page’s total revenue as more web monetized visitors access the site.
Since this method bypasses the need to include a monetization <link>
element, you can choose to use a payment pointer’s shorthand form (e.g., $wallet.example.com/alice
) rather than the endpoint URL that the payment pointer resolves to (e.g. https://wallet.example.com/alice
).
Next, we define the function to cause payment pointers to be chosen based on weight.
Finally, we add the code that dynamically inserts the randomly chosen payment pointer into the page on each load/refresh.
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 and no real payments are occurring.
If you see the source files instead of the example, click View App in the bottom right.