Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære 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.

Oppgave

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.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 5
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Campaign Analyzer

Sveip for å vise menyen

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.

Oppgave

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.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 3. Kapittel 5
single

single

some-alt