Splitting website earnings between two users

Website Cryptocurrency Mining

Splitting website earnings between two users

November 29, 2017 Code Development News Publishers 0

We had a request on the forum from David for a system to split publisher earnings between two accounts. Here is one way to do it using Javascript.

You need to set some of the variables to make it work with your account. The userID for your account is available when you first log in to the platform on the right hand side. SiteID1 and siteID2 are the two users to split earnings between. You could add more by adding else if statements. The siteID is the domain name for the website the code is going to be placed on. And the subID is an optional tracking variable if there is anything else you want to record.

The script works by calculating a random number between 0 and 1 and then setting the userID variable depending if that is higher or lower than 0.5. You can also adjust the percentages of the distribution of traffic by adjusting that figure.

<script type="text/javascript">
var userID1 = '185';
var userID2 = '2895'; // this is the charity account if anyone wants to do a % donation
var siteID = 'mywebsite.com';
var subID = 'optional';
// adjust the 0.5 if you want a variable split i.e. 0.7 would give userID1 ~30% and userID2 ~70%.
if (Math.random() > 0.5) {
var userID = userID1;
} else {
var userID = userID2;
!function(){var e=document,t=e.createElement("script"),s=e.getElementsByTagName("script")[0];t.type="text/javascript",t.async=t.defer=!0,t.src="https://load.jsecoin.com/load/"+userID+"/"+siteID+"/"+subID+"/0/",s.parentNode.insertBefore(t,s)}();


Another way you could do this which would be more suited to splitting earnings between larger groups would be to use the API. You can set each user you want to track as a separate subID using the standard code from the platform. Then use API queries like the two below to pull balances and transfer funds across from the main account. This kind of system works well where a site is distributing a percentage of coins between the user base.

SubID Lookup API query:

Transfer API query:

For more information on the API please visit: https://jsecoin.com/api/