Get Started

Calculating conversion rate

In this exercise, you will practice calculating conversion rate, which is often the first metric you'll want to calculate when evaluating how a marketing campaign performed.

On marketing teams, conversion rate is typically the most important metric. It is one of the best ways to determine how effective a marketing team was at gaining new customers.

As a reminder, conversion rate is the percentage of the users who saw our marketing assets and subsequently became subscribers.

The formula for conversion rate is:

$$ \frac{\text{Number of people who convert}}{\text{Total number of people who we market to}} $$

This is a part of the course

“Analyzing Marketing Campaigns with pandas”

View Course

Exercise instructions

  • Calculate the number of unique user_ids in marketing DataFrame.
  • Calculate the number of people who subscribed using the converted column.
  • Calculate the conversion rate.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Calculate the number of people we marketed to
total = ____

# Calculate the number of people who subscribed
subscribers = marketing[____]['user_id'].____

# Calculate the conversion rate
conversion_rate = ____
print(round(conversion_rate*100, 2), "%")

This exercise is part of the course

Analyzing Marketing Campaigns with pandas

BeginnerSkill Level
4.9+
15 reviews

Build up your pandas skills and answer marketing questions by merging, slicing, visualizing, and more!

In this chapter, you will learn about common marketing metrics and how to calculate them using pandas. You will also visualize your results and practice user segmentation.

Exercise 1: Introduction to common marketing metricsExercise 2: Calculating conversion rate
Exercise 3: Calculating retention rateExercise 4: Customer segmentationExercise 5: Comparing language conversion rate (I)Exercise 6: Comparing language conversion rate (II)Exercise 7: Aggregating by dateExercise 8: Plotting campaign results (I)Exercise 9: Visualize conversion rate by languageExercise 10: Creating daily conversion rate DataFrameExercise 11: Setting up our data to visualize daily conversionExercise 12: Visualize daily conversion rateExercise 13: Plotting campaign results (II)Exercise 14: Marketing channels across age groupsExercise 15: Grouping and counting by multiple columnsExercise 16: Analyzing retention rates for the campaign

What is DataCamp?

Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.

Start Learning for Free