Alright, let’s talk about “crown points”. I gotta tell ya, it was a bit of a journey, but I finally got it working. Here’s the lowdown:

So, first off, I wanted to implement a system where users could earn “crown points” for doing certain things on my app – kinda like a reward system to keep people engaged. Seemed simple enough, right?
Step 1: Defining the Actions
- First thing I did was list out all the activities that should earn points. Things like logging in daily, completing a profile, inviting friends, making a purchase – you know, the usual suspects.
- Then, I assigned point values to each action. Decided how many points each action was worth. Some were worth more than others.
Step 2: Setting up the Database
Then I had to get down to the nitty gritty. Jumped into my database and created a new table called “crown_points”. It had columns like:
- user_id: To link the points to a specific user.
- points: The number of points the user has.
- activity_type: Which activity earned the points (e.g., “daily_login”, “profile_complete”).
- timestamp: When the points were earned.
Step 3: Coding the Logic

Here’s where the real fun began. I started writing the code that would actually award the points. Used PHP, since that’s what my app is built on. Here’s the basic idea:
- First, I made a function called `awardCrownPoints($userId, $activityType)`. This function would take the user’s ID and the type of activity they did as input.
- Inside the function, I had a big `switch` statement that would determine how many points to award based on the `activityType`.
- Then, I’d update the `crown_points` table, adding a new row with the user’s ID, the points earned, the activity type, and the current timestamp. Also, I’d update the user’s total points in the users table.
Step 4: Implementing the Actions
Next, I went through my app and added calls to the `awardCrownPoints()` function wherever necessary. For example:
- In the login script, I added `awardCrownPoints($userId, ‘daily_login’)`.
- After a user completed their profile, I added `awardCrownPoints($userId, ‘profile_complete’)`.
Step 5: Displaying the Points
Of course, users need to see their points! I added a “Crown Points” section to their profile page. I just queried the `crown_points` table to get their total points and displayed it.

Step 6: Testing, Testing, 1, 2, 3
This is important! I did tons of testing. I created test accounts, logged in repeatedly, completed profiles, and made fake purchases just to make sure the points were being awarded correctly.
Step 7: Fine-Tuning and Optimization
After testing, I realized a few things needed tweaking. Some actions were giving too many points, others not enough. I also optimized the database queries to make things run faster.
Step 8: Launch!

Finally, after all that, I launched the “crown points” system! It’s been pretty successful so far. Users seem to like earning points, and it’s definitely increased engagement.
The Gotchas
- One thing I didn’t anticipate was people trying to game the system. I had to add some extra checks to prevent users from earning points for the same activity multiple times.
- I also had to think about point expiration. Didn’t want users hoarding points forever, so I implemented a system where points expire after a certain period.
Overall, implementing the crown points system was a fun and challenging project. It definitely taught me a lot about user engagement and database management. Hope this helps anyone else thinking about implementing something similar!