Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Campaign Analyzer | Optimizing Growth Experiments
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.

Tarefa

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.

Solução

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 5
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

close

bookChallenge: Campaign Analyzer

Deslize para mostrar o menu

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.

Tarefa

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.

Solução

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 5
single

single

some-alt