02 August 2016
Introducing Peanut Labs – monetization through surveys
A growing trend in app monetization is rewarding users for their time. We have seen rewarded video plugins, but there are other ways to engage your customers. Enter Peanut Labs, a monetization solution which lets your users take surveys from popular brands. You can reward your customers with virtual currency for taking the survey and you get paid for doing so. Your users will find a new and free way to earn credits every single day while having a quality customer experience.
“We are thrilled to partner with Corona Labs to boost the monetization opportunity for its developer community which will help app developers create extra revenue’’ says Noman Ali, Co-Founder and CEO of Peanut Labs.
Implementing Peanut Labs
Implementing the Peanut Labs plugin is pretty straightforward. Include the plugin in build.settings
, initialize it, and call the show() method. Of course, you will first need to apply for a developer account with Peanut Labs. Once they approve your account, you can log into their dashboard and start setting up your app. You will need an appKey
and an appId
which can be found in the dashboard. In addition, you will need to provide a unique userId
for each user. Rewards are tied to this ID. It’s just a string to them, so it can be any format in your app, but it needs to be unique. One option is to use a person’s Facebook ID, an email address, or some other ID.
There is a server-side requirement to use the Peanut Labs plugin. When you show a survey, the user will either be allowed to participate or they will be screened out due to demographics, previously completed surveys, etc. When the results are known, Peanut Labs servers will call a web script that you host on your web server. How you write that script and set up your database is completely up to you, since they expect you to have a server-based economy system in place. If you don’t, we have included a basic PHP script to handle their callback needs, in addition to a MySQL statement to create the table. Most web hosting providers offer MySQL databases and the ability to execute PHP scripts. See our documentation for these example scripts.
Completing the transaction
If the user completes the survey, you need to reward currency. But even if the user was screened out, they should still get a small reward. This encourages the user to try again another time, so when they do successfully complete a survey, you earn the revenue. After a survey attempt, Peanut Labs will update your server with information about the transaction. The data will indicate survey completion status, the amount of money you made, and an amount of virtual currency to give your user. You need to get that information to your app.
By their design, you should query your database, find that user’s information, and have your app react to the information found. Their system is set to work with games that drive an app’s full economic system on a server, so having the ability to inject the information into your system makes sense. However, if your app is not server-connected, you still need the information in your app. We’ve provided an additional PHP script which will query your database for the most recent entry from Peanut Labs. You can access this with network.request():
1 2 3 4 5 6 7 8 9 10 11 12 13 |
local json = require( "json" ) local function getResultListener( event ) if not event.isError then local result = json.decode( event.response ) print( json.prettify( result ) ) local currencyAmt = result.currencyAmount end end local URL = "https://yourserver.com/path/to/getresult.php?userId=" .. yourUserId network.request( URL, "GET", getResultListener ) |
Using this, you can compare the time stamp in the result with the current time using os.time(). If they are in close proximity to each other, it’s probably the transaction for the most recent survey completed. In this case, you can process the rewards.
Conclusion
Peanut Labs is a different kind of monetization tool that you can add to your arsenal. To learn more, visit their website and read our documentation and, if you have any further questions, please contact the Peanut Labs Team at [email protected]. Join us in the forums!
Sorry, the comment form is closed at this time.