Learn how to use Trophy to add an energy feature to your web or mobile app.
The guide outlines the full process of adding an energy feature to your web or mobile app using Trophy.For illustration purposes we’ll use the example of a study platform that uses energy to meter the rate at which users can view flashcards.
To see a fully working example of this in practice, check out the live
demo or github
repo.
In Trophy, Metrics are the building blocks of gamification and model the different interactions users make with your product.In this guide the interaction we’re interested in is flashcards-viewed, but you can create any number of metrics that best represents the interactions you want to grant and consume energy from.In the Trophy dashboard, head to the metrics page and create a metric.
Once you’ve created your metric, head to the points page and create a new points system called ‘Energy’.
Once created, you’ll be taken to the configure page for the energy system where you can create points triggers for each of the ways you want to grant or consume energy.
Use ‘time’ triggers to grant users with new energy on an hourly or daily basis, and use other types of triggers with negative values to consume energy from the different user interactions you want.In Trophy you track user interactions by sending Events from your code to Trophy APIs against a specific metric.When events are recorded for a specific user, Trophy will automatically check if any of the triggers set up against your energy system should be triggered, and process them accordingly.Trophy also takes care of automatically granting new energy to users over time in accordance with any ‘time’ triggers you’ve set up.This is what makes building gamified experiences with Trophy so easy, it does all the work for you behind the scenes.
The response to this API call is the complete set of changes to any features you’ve built with Trophy, including any changes in energy as a result of the event, and from what triggers energy was consumed.
You can then modify your trigger setup in Trophy and control the rate at which users can interact with your product right from the Trophy dashboard without needing to make any code changes.
curl --request GET \ --url https://api.trophy.so/v1/users/{id}/points/{key} \ --header 'X-API-KEY: <api-key>'
This API returns data on the user’s total energy but can be configured to also return between 1 and 100 of the user’s most recent energy changes by using the awardsquery parameter.
The user points summary API can also be used to drive chart-based UI, like showing users their energy usage over time.
Copy
Ask AI
curl --request GET \ --url https://api.trophy.so/v1/users/{id}/points/{key}/event-summary \ --header 'X-API-KEY: <api-key>'
Here’s an example of a UI that shows users their current energy, a chart showing their usage over time, and a list of their most recent changes in energy.
In Trophy your energy system page, includes analytics charts that shows data on total energy awarded/consumed and a breakdown of exactly what triggers cause the most frequent changes in energy.