Marketing campaign performance analysis
Analyze and optimize marketing campaign performance in real-time.
Overview
In a fast-paced marketing environment, marketers and campaign managers must collaborate to optimize customer engagement and maximize conversion rates. Measuring the impact of each new marketing campaign quickly and accurately is challenging, which can lead to missed opportunities. Being able to promptly determine whether or not a campaign was effective allows the business to adjust marketing strategies dynamically in response to customer behavior.
Real-time processing and analysis of customer engagement data enables analysts to monitor campaign performance as it happens. They can determine what strategies are working and adapt based on emerging trends. This approach improves ROI and ensures marketing efforts are appealing to customer preferences.
In this tutorial, you will learn how to analyze the effects of a market campaign in real-time.
Prerequisites
- Ensure that the PostgreSQL interactive terminal,
psql
, is installed in your environment. For detailed instructions, see Download PostgreSQL. - Install and run RisingWave. For detailed instructions on how to quickly get started, see the Quick start guide.
- Ensure that a Python environment is set up and install the psycopg2 library.
Step 1: Set up the data source tables
Once RisingWave is installed and deployed, run the three SQL queries below to set up the tables. You will insert data into these tables to simulate live data streams.
-
The
marketing_events
table tracks user interactions with marketing campaigns and includes details, such as the number of clicks and impressions, of each event. -
The
campaigns
table stores information about each marketing campaign, such as what type of campaign it was and the target audience. -
The
ab_test_variants
contains details, such as the variant type and name, about A/B test variations for campaigns.
Step 2: Run the data generator
To keep this demo simple, a Python script is used to generate and insert data into the tables created above.
Clone the awesome-stream-processing repository.
Navigate to the market_analysis folder.
Run the data_generator.py
file. This Python script utilizes the psycopg2
library to establish a connection with RisingWave so you can generate and insert synthetic data into the three tables described above.
If you are not running RisingWave locally or using default credentials, update the connection parameters accordingly:
Step 3: Create materialized views
In this demo, you will create multiple materialized views to investigate the efficacy of marketing campaigns.
Materialized views contain the results of a view expression and are stored in the RisingWave database. The results of a materialized view are computed incrementally and updated whenever new events arrive and do not require to be refreshed. When you query from a materialized view, it will return the most up-to-date computation results.
Evaluate campaign metrics
The campaign_performance
materialized view summarizes the performance metrics of the marketing campaigns over 1-hour time windows. The tumble
function is used to map each event into a 1-hour time window.
You will gain insight into key performance indicators for each campaign, such as the number of impressions, clicks, and conversions.
You can query from campaign_performance
to see the results.
Analyze marketing channels
The channel_attribution
materialized view analyzes the marketing performance over 1-hour time windows. Again, the tumble
function is used to map each event into a 1-hour time window. Then, you group by the time window and channel type to find the aggregate channel metrics.
This materialized view helps to show the effectiveness of each marketing channel in driving conversion and revenue. It provides details such as the number of unique, engaged users, and the total revenue generated by each channel.
You can query from channel_attribution
to see the results.
Assess A/B tests
The ab_test_results
materialized view analyzes the results of the A/B test over 1-hour time windows. A multi-way join is used to retrieve campaign details and details on the test variations.
This materialized view allows you to evaluate the A/B test and determine which test variant performed best. From there, you can make more informed decisions on which marketing campaign to move forward with.
You can query from ab_test_results
to see the results.
When finished, press Ctrl+C
to close the connection between RisingWave and psycopg2
.
Summary
In this tutorial, you learn:
- How to evaluate an A/B test in real time.
Was this page helpful?