Skip to content

Commit 4ea55e5

Browse files
authored
Merge pull request #227 from DataExpert-io/feature-kpis-experimentation
adding kpis and experimentation
2 parents 2d3954e + 5d30ddb commit 4ea55e5

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# SPOTIFY’S KPI AND EXPERIMENTATION
2+
I am going to discuss about Spotify. I have used Spotify for 4 years. I am a big music fan, and I cannot live my life without music. Back when I just started using such app, Apple music and Spotify were the two biggest music streaming apps. But I am an Android user, so by default, Spotify is my option. However, I would choose Spotify either way because most of my friends use Spotify, I can connect to my network easier. Spotify UI is more pleasing to the eyes and it has better recommendations on music than Apple Music. I discovered so many good songs from their recommendation systems. They also got me thrilled everytime they released the end-of-year music recap.
3+
Now, I also discover Youtube music and I like it as well since it has a lot of older and international songs. Youtube is also really good while partnering with other service such as phone carrier Google Fi, Spectrum. Spotify so far only has student plan and Hulu promotion. In my opinion, Spotify might face a market share loss to Youtube Music in the future.
4+
For this reason, I am going to run 3 experiments to keep me interested in Spotify and loyal as a user.
5+
## Experiment 1: Spotify's Gym Combo vs. Hulu Deal - A Revenue Sign-Up Experiment
6+
**Objective:** Users love combo deals, therefore Spotify is launching some deals to lure there perspective users to sign up. Currently, Spotify is having deal with Hulu. However, that is not a good combo. Since people go to the gym usually listen to beats, Spotify offers discounted deal for Spotify premium and Blink monthly membership. The goal is to see if Blink combo performs better than Hulu one in terms of sign-up revenue.
7+
8+
**Null Hypothesis:** Blink combo does not perform better than Hulu one in terms of sign-up revenue.
9+
10+
**Alternative Hypothesis:** Blink combo performs better than Hulu one in terms of sign-up revenue.
11+
12+
**Leading Metric:** Number of users who sign up after launching the Blink combo.
13+
14+
**Lagging Metric:** Increase in sign-up sale.
15+
16+
**Test cell allocation:** 50%-50%
17+
## Experiment 2: Friend Podcast Listening and User Engagement Tracking
18+
**Objective:** Personally, I am curious about what podcast my friends are listening to and I wish there was a podcast viewing feature. I think it could affect the podcast listeners engagement. The goal is to determine whether allowing users to view what podcasts their friends are listening to positively impacts user engagement with podcasts on the platform.
19+
20+
**Null Hypothesis:** There is no significant difference in user engagement with podcasts between users who can view what podcasts their friends are listening to and users who cannot.
21+
22+
**Alternative Hypothesis:** There is significant difference in user engagement with podcasts between users who can view what podcasts their friends are listening to and users who cannot.
23+
24+
**Leading metrics:** An increase in the frequency of users checking this feature might predict higher engagement with podcasts in the future.
25+
26+
**Lagging metrics:** The percentage of users who continue to use the platform and engage with podcasts over a specified period.
27+
28+
**Test cell allocation:** 50%-50%
29+
## Experiment 3: Changing Sign-Up Ads to Enhance User Engagement
30+
**Objective:** To determine whether changing the sign-up ad from "Try 3 months free" to "Your friend is listening to this song, wanna hear it" positively impacts user sign-up rates and engagement on the platform.
31+
32+
**Null Hypothesis:** There is no significant difference in user sign-up rates between the "Try 3 months free" and "Your friend is listening to this song, wanna hear it" ad variations.
33+
34+
**Alternative Hypothesis:** Users who see the "Your friend is listening to this song, wanna hear it" ad will have a significantly higher sign-up rate compared to those who see the "Try 3 months free" ad.
35+
36+
**Leading metrics:** the amount of time users spend on Spotify after signing up.
37+
38+
**Lagging metrics:** the percentage of users who convert from free to premium subscribers after signing up.
39+
40+
**Test cell allocation:** 50%-50%
41+
42+
43+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Homework
2+
3+
- Pick a product that you love using (spotify, linkedin, etc)
4+
- Describe the user journey of the things you loved about it from the moment you started using it to your use of it now
5+
- Describe 3 experiments you would like to run on this product to see if it would improve the experience
6+
- You should detail out the allocation of each test cell and the different conditions you’re testing
7+
- Your hypothesis of which leading and lagging metrics would be impacted by this experiment
8+
9+
- Put these files in Markdown files and submit [here](https://bootcamp.techcreator.io/assignments)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Flask
2+
request
3+
jsonify
4+
statsig
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
from flask import Flask, jsonify, request
2+
from statsig import statsig
3+
from statsig.statsig_event import StatsigEvent
4+
from statsig.statsig_user import StatsigUser
5+
import random
6+
import os
7+
8+
API_KEY = os.environ.get('STATSIG_API_KEY')
9+
statsig.initialize(API_KEY)
10+
app = Flask(__name__)
11+
12+
# Sample in-memory database
13+
tasks = [
14+
{
15+
'id': 1,
16+
'title': 'Do the dishes',
17+
'description': 'Odd Tasks',
18+
'done': False
19+
},
20+
{
21+
'id': 2,
22+
'title': 'Study for exam',
23+
'description': 'Even Tasks',
24+
'done': False
25+
}
26+
]
27+
28+
29+
@app.route('/')
30+
def hello():
31+
return "Hello, this is a Flask API!"
32+
33+
34+
@app.route('/signup')
35+
def signup():
36+
random_num = request.args.get('random')
37+
hash_string = request.remote_addr
38+
if random_num:
39+
hash_string = str(random.randint(0, 1000000))
40+
user_id = str(hash(hash_string))
41+
statsig_user = StatsigUser(user_id)
42+
statsig_event = StatsigEvent(
43+
user=statsig_user,
44+
event_name='visited_signup'
45+
)
46+
statsig.log_event(statsig_event)
47+
return "This is the signup page"
48+
49+
50+
@app.route('/tasks', methods=['GET'])
51+
def get_tasks():
52+
random_num = request.args.get('random')
53+
hash_string = request.remote_addr
54+
if random_num:
55+
hash_string = str(random.randint(0, 1000000))
56+
user_id = str(hash(hash_string))
57+
color = statsig.get_experiment(StatsigUser(user_id), "button_color_v3").get("Button Color", "blue")
58+
paragraph_text = statsig.get_experiment(StatsigUser(user_id), "button_color_v3").get("Paragraph Text", "Data Engineering Boot Camp")
59+
experiment_description = 'odd tasks for blue and green, even for red and orange'
60+
filtered_tasks = ''.join(map(lambda a: f"""
61+
<tr>
62+
<td>
63+
{a['id']}
64+
</td>
65+
<td>
66+
{a['title']}
67+
</td>
68+
<td>
69+
{a['description']}
70+
</td>
71+
<td>
72+
{a['done']}
73+
</td>
74+
75+
</tr>
76+
""", list(filter(lambda x: x['id'] % 2 == (0 if color == 'Red' or color == 'Orange' else 1), tasks))))
77+
return f"""
78+
<div style="{"background: " + color}">
79+
<h1>{"experiment group: " + color}</h1>
80+
<h2>{"experiment description: " + experiment_description}</h2>
81+
<h5>{"current user identifier is: <i>" + user_id}</i></h5>
82+
<h5>{paragraph_text}</h5>
83+
<table>
84+
<thead>
85+
<th>Id</th>
86+
<th>Title</th>
87+
<th>Description</th>
88+
<th>Done</th>
89+
</thead>
90+
<tbody>
91+
{filtered_tasks}
92+
</tbody>
93+
</table>
94+
<a href="/signup">Go to Signup</a>
95+
</div>
96+
"""
97+
98+
@app.route('/tasks/<int:task_id>', methods=['GET'])
99+
def get_task(task_id):
100+
task = next((task for task in tasks if task['id'] == task_id), None)
101+
if task:
102+
return jsonify({'task': task})
103+
return jsonify({'error': 'Task not found'}), 404
104+
105+
106+
@app.route('/tasks', methods=['POST'])
107+
def create_task():
108+
if not request.json or not 'title' in request.json:
109+
return jsonify({'error': 'The new task must have a title'}), 400
110+
task = {
111+
'id': tasks[-1]['id'] + 1 if tasks else 1,
112+
'title': request.json['title'],
113+
'description': request.json.get('description', ""),
114+
'done': False
115+
}
116+
tasks.append(task)
117+
return jsonify({'task': task}), 201
118+
119+
120+
@app.route('/tasks/<int:task_id>', methods=['PUT'])
121+
def update_task(task_id):
122+
task = next((task for task in tasks if task['id'] == task_id), None)
123+
if not task:
124+
return jsonify({'error': 'Task not found'}), 404
125+
if not request.json:
126+
return jsonify({'error': 'Malformed request'}), 400
127+
task['title'] = request.json.get('title', task['title'])
128+
task['description'] = request.json.get('description', task['description'])
129+
task['done'] = request.json.get('done', task['done'])
130+
return jsonify({'task': task})
131+
132+
133+
@app.route('/tasks/<int:task_id>', methods=['DELETE'])
134+
def delete_task(task_id):
135+
global tasks
136+
tasks = [task for task in tasks if task['id'] != task_id]
137+
return jsonify({'result': True})
138+
139+
140+
if __name__ == '__main__':
141+
app.run(debug=True)

0 commit comments

Comments
 (0)