Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Oppiskele Challenge: Campaign Analyzer | Optimizing Growth Experiments
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Growth Hackers

bookChallenge: Campaign Analyzer

In growth hacking, comparing the effectiveness of different marketing campaigns is crucial for optimizing your strategies. You can use Python to automate the analysis of campaign data, allowing you to quickly identify which campaigns are performing best based on metrics like click-through rate (CTR) and conversion rate. Suppose you have a set of campaigns, each with data on impressions, clicks, and conversions. By calculating the CTR and conversion rate for each campaign, you can determine which one is converting users most effectively and focus your efforts on scaling what works.

12345678910111213141516171819
import pandas as pd # Create a DataFrame with campaign data data = { "campaign": ["Spring Launch", "Summer Sale", "Fall Promo", "Winter Clearance"], "impressions": [10000, 15000, 12000, 8000], "clicks": [500, 900, 480, 320], "conversions": [50, 120, 36, 40] } df = pd.DataFrame(data) # Calculate click-through rate (CTR) and conversion rate df["ctr"] = df["clicks"] / df["impressions"] df["conversion_rate"] = df["conversions"] / df["clicks"] # Print the campaign with the highest conversion rate best_campaign = df.loc[df["conversion_rate"].idxmax()] print("Campaign with highest conversion rate:") print(f"{best_campaign['campaign']} (Conversion Rate: {best_campaign['conversion_rate']:.2%})")
copy

This script begins by building a pandas DataFrame with hardcoded data for four campaigns, including the number of impressions, clicks, and conversions. It then calculates the CTR by dividing clicks by impressions and the conversion rate by dividing conversions by clicks for each campaign. Finally, it identifies and prints the campaign with the highest conversion rate, making it easy to see which campaign is most effective at turning clicks into conversions.

Tehtävä

Swipe to start coding

Write a Python script that analyzes marketing campaign performance using pandas.

  • Create a pandas DataFrame from the provided campaign_data dictionary;
  • Calculate a new column ctr as the ratio of clicks to impressions for each campaign;
  • Calculate a new column conversion_rate as the ratio of conversions to clicks for each campaign;
  • Identify which campaign has the highest conversion_rate and assign its name (as a string) to a variable called top_campaign.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 5
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookChallenge: Campaign Analyzer

Pyyhkäise näyttääksesi valikon

In growth hacking, comparing the effectiveness of different marketing campaigns is crucial for optimizing your strategies. You can use Python to automate the analysis of campaign data, allowing you to quickly identify which campaigns are performing best based on metrics like click-through rate (CTR) and conversion rate. Suppose you have a set of campaigns, each with data on impressions, clicks, and conversions. By calculating the CTR and conversion rate for each campaign, you can determine which one is converting users most effectively and focus your efforts on scaling what works.

12345678910111213141516171819
import pandas as pd # Create a DataFrame with campaign data data = { "campaign": ["Spring Launch", "Summer Sale", "Fall Promo", "Winter Clearance"], "impressions": [10000, 15000, 12000, 8000], "clicks": [500, 900, 480, 320], "conversions": [50, 120, 36, 40] } df = pd.DataFrame(data) # Calculate click-through rate (CTR) and conversion rate df["ctr"] = df["clicks"] / df["impressions"] df["conversion_rate"] = df["conversions"] / df["clicks"] # Print the campaign with the highest conversion rate best_campaign = df.loc[df["conversion_rate"].idxmax()] print("Campaign with highest conversion rate:") print(f"{best_campaign['campaign']} (Conversion Rate: {best_campaign['conversion_rate']:.2%})")
copy

This script begins by building a pandas DataFrame with hardcoded data for four campaigns, including the number of impressions, clicks, and conversions. It then calculates the CTR by dividing clicks by impressions and the conversion rate by dividing conversions by clicks for each campaign. Finally, it identifies and prints the campaign with the highest conversion rate, making it easy to see which campaign is most effective at turning clicks into conversions.

Tehtävä

Swipe to start coding

Write a Python script that analyzes marketing campaign performance using pandas.

  • Create a pandas DataFrame from the provided campaign_data dictionary;
  • Calculate a new column ctr as the ratio of clicks to impressions for each campaign;
  • Calculate a new column conversion_rate as the ratio of conversions to clicks for each campaign;
  • Identify which campaign has the highest conversion_rate and assign its name (as a string) to a variable called top_campaign.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 3. Luku 5
single

single

some-alt