Data Analytics for Marketing: A practical guide to analyzing marketing data using Python
()
Related to Data Analytics for Marketing
Related ebooks
Marketing Analytics: How to Achieve Success, #1 Rating: 0 out of 5 stars0 ratingsImpact for Marketing Data Analytics Making Data-Driven Decisions: IMPACT Marketing Series: A Complete Courses, #13 Rating: 0 out of 5 stars0 ratingsEffective Analytics for Marketing Rating: 0 out of 5 stars0 ratingsMachine Learning and Generative AI for Marketing: Take your data-driven marketing strategies to the next level using Python Rating: 0 out of 5 stars0 ratingsMarketing Analytics: 7 Easy Steps to Master Marketing Metrics, Data Analysis, Consumer Insights & Forecasting Modeling Rating: 0 out of 5 stars0 ratingsMastering Data Analytics: For Absolute Beginners To Business Intelligence Rating: 0 out of 5 stars0 ratingsBusiness Analytics: A Comprehensive Guide Rating: 0 out of 5 stars0 ratingsMARKETING DATA ANALYST HANDBOOK: A DATA WHISPERERS DREAM Rating: 0 out of 5 stars0 ratingsMarketing Metrics: 3-in-1 Guide to Master Marketing Analytics, Key Performance Indicators (KPI's) & Marketing Automation Rating: 0 out of 5 stars0 ratingsData Science for Decision Makers: Enhance your leadership skills with data science and AI expertise Rating: 0 out of 5 stars0 ratingsCrawl, Walk, Run: Advancing Analytics Maturity with Google Marketing Platform Rating: 0 out of 5 stars0 ratingsHow To Win Customers Every Day _ Volume 7: Data-Driven Selling: The Complete Guide to Success Rating: 0 out of 5 stars0 ratingsBuilding Winning Strategies With Analytics Rating: 0 out of 5 stars0 ratingsRetail Data Analytics: Enhancing Customer Experience and Profitability Rating: 0 out of 5 stars0 ratingsBuilding Better Models with JMP Pro Rating: 0 out of 5 stars0 ratingsFrom Data To Decisions: Driving Performance in the Age of Analytics Rating: 0 out of 5 stars0 ratingsDriving Strategy and Innovation with Analytics Rating: 0 out of 5 stars0 ratingsData Analytics with Generative AI Rating: 0 out of 5 stars0 ratingsData Analytics and Data Processing Essentials Rating: 0 out of 5 stars0 ratingsDelivering Business Analytics: Practical Guidelines for Best Practice Rating: 3 out of 5 stars3/5Excel Data Mastery for Beginners Rating: 0 out of 5 stars0 ratingsData Insights: The Science of Data Analysis Rating: 0 out of 5 stars0 ratingsWi-Fi Tracking in Retail Industry Rating: 0 out of 5 stars0 ratingsEssentials of Data Analysis Rating: 0 out of 5 stars0 ratingsIntroduction to Business Analytics Rating: 0 out of 5 stars0 ratings
Computers For You
Mastering ChatGPT: 21 Prompts Templates for Effortless Writing Rating: 4 out of 5 stars4/5The ChatGPT Millionaire Handbook: Make Money Online With the Power of AI Technology Rating: 4 out of 5 stars4/5Standard Deviations: Flawed Assumptions, Tortured Data, and Other Ways to Lie with Statistics Rating: 4 out of 5 stars4/5Elon Musk Rating: 4 out of 5 stars4/5The Self-Taught Computer Scientist: The Beginner's Guide to Data Structures & Algorithms Rating: 0 out of 5 stars0 ratingsSQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5CompTIA IT Fundamentals (ITF+) Study Guide: Exam FC0-U61 Rating: 0 out of 5 stars0 ratingsDeep Search: How to Explore the Internet More Effectively Rating: 5 out of 5 stars5/5Alan Turing: The Enigma: The Book That Inspired the Film The Imitation Game - Updated Edition Rating: 4 out of 5 stars4/5Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5How to Create Cpn Numbers the Right way: A Step by Step Guide to Creating cpn Numbers Legally Rating: 4 out of 5 stars4/5UX/UI Design Playbook Rating: 4 out of 5 stars4/5Fundamentals of Programming: Using Python Rating: 5 out of 5 stars5/5The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution Rating: 4 out of 5 stars4/5CompTIA Security+ Get Certified Get Ahead: SY0-701 Study Guide Rating: 5 out of 5 stars5/52022 Adobe® Premiere Pro Guide For Filmmakers and YouTubers Rating: 5 out of 5 stars5/5An Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5Excel 101: A Beginner's & Intermediate's Guide for Mastering the Quintessence of Microsoft Excel (2010-2019 & 365) in no time! Rating: 0 out of 5 stars0 ratingsSlenderman: Online Obsession, Mental Illness, and the Violent Crime of Two Midwestern Girls Rating: 4 out of 5 stars4/5Tor and the Dark Art of Anonymity Rating: 5 out of 5 stars5/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Excel Tables: A Complete Guide for Creating, Using and Automating Lists and Tables Rating: 5 out of 5 stars5/5Procreate for Beginners: Introduction to Procreate for Drawing and Illustrating on the iPad Rating: 5 out of 5 stars5/5Get Into UX: A foolproof guide to getting your first user experience job Rating: 4 out of 5 stars4/5The Musician's Ai Handbook: Enhance And Promote Your Music With Artificial Intelligence Rating: 5 out of 5 stars5/5
Reviews for Data Analytics for Marketing
0 ratings0 reviews
Book preview
Data Analytics for Marketing - Guilherme Diaz-Bérrio
Data Analytics for Marketing
Copyright © 2024 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Group Product Manager: Kaustubh Manglurkar
Publishing Product Manager: Heramb Bhavsar
Book Project Managers: Farheen Fathima and Shambhavi Mishra
Senior Editor: Rohit Singh
Technical Editor: Rahul Limbachiya
Copy Editor: Safis Editing
Proofreaders: Rohit Singh and Safis Editing
Indexer: Subalakshmi Govindhan
Production Designer: Joshua Misquitta
DevRel Marketing Executive: Nivedita Singh
First published: May 2024
Production reference: 1120424
Published by Packt Publishing Ltd.
Grosvenor House
11 St Paul’s Square
Birmingham
B3 1RB, UK.
ISBN 978-1-80324-160-9
To Andreia Lopes, my partner. You are my safe harbor; this book would not have become a reality without your support during the endless hours I thought about giving up. You make me want to be better, and I would not be where I am without you. Love you!
– Guilherme Diaz-Bérrio
Contributors
About the author
Guilherme Diaz-Bérrio is the Head of Marketing Analytics at Kindred Group, one of the 10 largest gambling operators. He helps improve marketing efforts across various platforms. His career started in finance at a hedge fund and moved through the automotive industry at BMW Group and BMW Financial Services, before coming to Kindred Group. He graduated with a degree in economics from ISEG, University of Lisbon, and has additional training in data science and econometrics. He is also the co-founder of Pinemarsh, a data analytics and digital marketing consulting firm.
I want to thank my editor, Rohit Singh, for his help and patience in reviewing my drafts. I also want to thank Birjees Patel and Deepesh Patel, for taking a chance and inviting me to write this book. I would like to thank the reviewers, Devanshu Tayal, Shubham Gupta, and Michael Van Den Reym. Their feedback was incredibly helpful in getting to the final drafts. Finally, I would like to thank Krishna Bhaskaran, for giving me the opportunity to work in marketing analytics and giving me the foundations of what I know today.
About the reviewers
Devanshu Tayal is a highly accomplished data scientist with a master’s degree from BITS, Pilani, India. His extensive expertise in data science is evidenced by his contributions to a wide range of industries. Devanshu is deeply committed to mentoring and guiding aspiring data scientists and is an avid researcher of emerging technologies in the field. He is a strong advocate for diversity and inclusion and has shared his insights through various publications. Devanshu is frequently invited to deliver guest lectures at universities throughout India, and his contributions as a technical reviewer have been acknowledged in multiple books. His comprehensive knowledge and experience in the field make him an asset to any team or project.
Shubham Gupta, an accomplished technology leader and a staunch advocate for data-driven decision-making, possesses a vast wealth of expertise spanning analytics, business intelligence, strategic planning, and cutting-edge innovative solutions. His deep comprehension of both technological intricacies and business dynamics equips him to guide business stakeholders from a wide array of industries toward making well-informed, data-backed decisions, thus streamlining operations and fostering substantial growth.
Furthermore, Shubham’s significant involvement as a judge for numerous prestigious tech awards highlights his unwavering dedication to promoting excellence and driving innovation within the tech industry.
Michael Van Den Reym is a seasoned professional in the field of digital analytics and search engine optimization, with a rich background in enhancing online visibility for diverse businesses. Currently, he’s working at iO, the biggest full-service digital agency in Belgium. Michael has been a speaker on data-driven marketing at industry conferences such as MeasureCamp, MeasureFest, and BrightonSEO. Michael’s work primarily revolves around leveraging data-driven insights using Python and data visualization tools to create strategies that significantly improve digital marketing outcomes.
Currently, Michael is working on his first book, Fundamentals of SEO for Business, which revolves around search engine optimization for marketing professionals.
Table of Contents
Preface
Part 1: Fundamentals of Analytics
1
What is Marketing Analytics?
What is analytics?
An overview of marketing analytics
Why should we bother with marketing analytics?
Exploring different types of analytics
Descriptive analytics
Diagnostic analytics
Predictive analytics
Prescriptive analytics
Walking through the maze of tools and techniques
Beyond simple pivot tables
Why Python?
Modern challenges in the world of privacy-centric marketing
The importance of data engineering and tracking
Don’t moonlight as a data engineer
Web tracking is hard, and it is becoming harder
Summary
Further reading
2
Extracting and Exploring Data with Singer and pandas
Technical requirements
What is ETL, and why should you care?
Data pipelines
What is Singer?
Summarizing data and EDA
Primer on descriptive statistics
Percentiles, quantiles, and distributions
Measures of central tendency
Measures of variability
Dealing with common data issues
Bill Gates walks into a bar
Missing values and data imputation
Digging deeper into variable transformations
Data standardization or scaling
Power transformations
Summary
Further reading
3
Design Principles and Presenting Results with Streamlit
Technical requirements
Types of dashboards and their design
Understanding the design concepts of a dashboard
Thinking about how to best present data
Thinking a bit about processing information
Generating effective filters, dimensions, and metrics
Filters
Dimensions
Metrics
Getting your data into Streamlit and generating a basic dashboard
Starting out with Streamlit
Creating a marketing data dashboard with Streamlit
Summary
Further reading
4
Econometrics and Causal Inference with Statsmodels and PyMC
Technical requirements
What is a linear regression?
What is a model?
What are the assumptions of a linear regression?
Exploring different types of regression models
What we can do when the assumptions break down
How to do a linear regression
What is logistic regression?
Objectives of logistic regression models
Odds of an event
What is causal inference?
Correlation, causation, and key drivers
A more practical application
A small detour through the backdoor
Watch out for colliders
Summary
Further reading
Part 2: Planning Ahead
5
Forecasting with Prophet, ARIMA, and Other Models Using StatsForecast
Technical requirements
What is forecasting?
Why forecasting is important
Types of times series data
Exploratory data analysis
What to forecast
Weekly, daily, and sub-daily data
Time series of counts
Prediction intervals for aggregates
Long and short time series
Transformations
What types of patterns are present?
Time series decomposition
Time series features
Basics of time series forecasting
Simple methods
Fitted values and residuals
Correlation and forecasting
Variable selection in time series regression models
Advanced forecasting methods
Extending regression models to time series
ETS models
ARIMA models
The Prophet model
Which model to use
Summary
Further reading
6
Anomaly Detection with StatsForecast and PyMC
Technical requirements
What is an anomaly?
Techniques to detect anomalies
Anomaly detection with STL decomposition
Twitter’s t-ESD algorithm for anomaly detection
Isolation forests for anomaly detection
Forecasting as an anomaly detection tool
Practical implementation with StatsForecast
Using rates of arrival to identify change points
Pros and cons of using rates of arrival for change point detection
Summary
Further reading
Part 3: Who and What to Target
7
Customer Insights – Segmentation and RFM
Technical requirements
Understanding the sources of customer dynamics
Analyzing customer dynamics – unveiling segmentation and RFM
Delving deeper into what segmentation is
Clustering
Classification
Discriminant analysis and classification
Exploring RFM
Approaches and techniques – independent versus sequential sorting
A practical example of RFM analysis
Profitability evaluation
ROMI after RFM
Results of using RFM for targeting
Summary
Further reading
8
Customer Lifetime Value with PyMC Marketing
Technical requirements
Diving deeper into CLV
CLV in practice
Using CLV to calculate acquisition costs
CLV and prospects
CLV and incremental value
What’s wrong with the CLV formula?
Issue 1
Issue 2
Issue 3
Issue 4
Issue 5
Beyond the CLV formula
The BTYD model
The Pareto/NBD model
The BG/NBD model
Implementing the BTYD model using PyMC Marketing
Predicting the expected number of purchases for a new customer
Estimating the CLV
Summary
Further reading
9
Customer Survey Analysis
Technical requirements
Steps in customer survey analysis
Questionnaire construction
Principles of questionnaire design
Types of questions
Asking questions
Questionnaire design—layout
Response formats
Reliability and validity
Reliability and classical measurement theory
Standard error of measurement
Using scales with high reliability
How to do sampling
Types of sampling
Probability versus quota sampling
Sample size for estimating population mean
Response rate
Control charts
Customer loyalty and NPS methodology
Issues with NPS
Potential loss of revenue
Advocacy, purchasing, and retention loyalty
Factor analysis
Summary
Further reading
10
Conjoint Analysis with pandas and Statsmodels
Technical requirements
An introduction to conjoint analysis
The fundamentals of conjoint analysis
Setting up a conjoint study
Step 1 – select the product attributes to be included
Step 2 – select the product attribute levels
Step 3 – create product profiles
Step 4 – collect data from target customers
Step 5 – estimate the utility of each product attribute and levels using regression analysis
Conducting conjoint analysis in Python
Determining the value of a product attribute
Choice-based conjoint analysis
Reporting findings
Summary
Further reading
Part 4: Measuring Effectiveness
11
Multi-Touch Digital Attribution
Technical requirements
An introduction to attribution models
Heuristic attribution models
The implementation of different heuristic attribution models
Algorithmic attribution models
Shapley value attribution
Fractribution
Summary
Further reading
12
Media Mix Modeling with PyMC Marketing
Technical requirements
Understanding MMM
MMM versus MTA versus lift analysis and A/B testing
Steps toward implementing MMM
Data collection
How much data to collect
Modeling
How to measure the adstock effect
Saturation and diminishing returns
Which comes first?
Selecting a model
Experimenting and calibrating
A synthetic data example of MMM
Synthetic data generation
Modeling
Model results
Summary
Further reading
13
Running Experiments with PyMC
Technical requirements
What makes a good experiment?
A/A testing
Type I and Type II errors
p-values
Common pitfalls
Delving deeper into some pitfalls
Conversion rate
Uplift modeling
Experimentation
Observational studies
Quasi-experiments
Difference in differences
Synthetic control and causal impact
Summary
Further reading
Index
Other Books You May Enjoy
Preface
When I first started as a marketing data analyst, I felt lost. I already knew how to program in Python, and the basics of statistics and econometrics, but marketing analytics is a surprisingly deceptive field. It feels easy, but due to the nature of the data we work with, it involves more complex models than you initially thought; correlation is often confused with causation, and sometimes, you just feel like you are flying blind. Either that or you feel like a glorified pivot table maker. A lot of my knowledge then came from trial and error: testing techniques, reading up on new methods, and making mistakes… a lot of mistakes.
When I started managing and hiring a team of analysts, I sometimes felt that it would make my life easier if I could just point them to a book that gave them the basics instead of spending hours in one-on-one sessions explaining methods or techniques. This book is my attempt at that: a summary of the fundamentals of marketing analytics, above simple pivot table making.
Marketing analytics is an incredibly complex field, and it is impossible to encapsulate all of it in one book. This book aims to give you, the reader, a grounding understanding of the techniques and tools most used in marketing analytics. The aim is to provide a practical, no-nonsense approach. You will have to have some basic understanding of the theoretical aspects surrounding tools and models so that you know what you are using and why, but we will quickly shift to a practical approach. The ultimate goal of this book is to equip you with the practical knowledge to get operational as a marketing data analyst quickly. This book will present open source libraries that allow you to derive insights quickly and use examples of common questions you will face daily as a marketing analyst.
There are gaps and techniques we will not explore. Marketing analytics is an ever-evolving field, and writing a book to cover everything would take more than 5,000 pages. Each chapter could be, and sometimes is, its own book. This book aims to equip you with fundamental knowledge, give you an overview of what is available, and provide some understanding of how to apply it. It also aims to give you the biggest asset an experienced analyst can have – knowing what to look for and research when facing a new problem. This last point is, for me, the most important. If this book achieves nothing else, let it be that it provides you with the compass to find the tools and techniques you need in your daily life. Even if that means you will disagree with me on a specific technique, that will be a win.
Throughout the book, we will use Python and its rich data analysis and statistics package ecosystem.
Who this book is for
There are some assumptions I have about who you are as a reader. Although an attempt is made to explain the most complex Python code snippets, you need to have a basic understanding of Python and be comfortable with it. By comfortable, I mean you know what a function is, how to define it, how to import a module, and the basic language syntax. Another requirement is you should not be afraid of mathematics. This point is contentious, but some chapters will have some formulation and theory before we get into actual code. Some people might disagree, but while copilots such as GitHub Copilot or ChatGPT can help you produce the code, you still need fundamental theoretical knowledge. In fact, with code copilots becoming better and better, most likely, the distinction between a good and an average analyst will be the theoretical grounding they have. I will attempt to give you the basic toolbelt of math techniques early on, starting from how to calculate a mean, but this book assumes you are comfortable with high-school-level mathematical notation.
This book is primarily aimed at data analysts who want to understand the full suite of techniques available to them in marketing analytics. You can also be a marketing professional aiming to move to the analytical side, but if this is you, I advise you to first brush up on the basics of Python programming, math, and statistics.
What this book covers
Chapter 1
, What is Marketing Analytics?, delves into what we mean by marketing analytics, breaking down the types of analytics, from descriptive to prescriptive, what value they add to the business, and what questions each of them answers.
Chapter 2
, Extracting and Exploring Data with Singer and pandas, gives you a brief introduction to ETL and how to extract and handle marketing data, ingestion, and Exploratory Data Analysis (EDA). We will cover the fundamentals of descriptive statistics and go through common data transformations to ensure data normality.
Chapter 3
, Design Principles and Presenting Results with Streamlit, takes us through how to properly design a dashboard for marketing data, from design principles to actual implementation. This is instrumental in displaying our results in a presentable way to non-technical audiences.
Chapter 4
, Econometrics and Causal Inference with Statsmodels and PyMC, deals with the fact that, as a marketing analyst, you usually do not have the luxury of big data to feed into machine learning models. The data will be sparse or low-frequency time series or panel data, which will prevent you from brute-forcing your way through. You need a solid understanding of econometrics and the principles of causality to answer common questions your stakeholders will have.
Chapter 5
, Forecasting with Prophet, ARIMA, and Other Models Using StatsForecast, digs deeper into forecasting. Forecasting is one of the fundamental tasks of a marketing data analyst. It is also one of the most complex fields in statistics. You should understand which models to apply, when to apply them, and what to avoid. We will review the most common models, from ARIMA to ETS, and what are the common pitfalls in forecasting time series.
Chapter 6
, Anomaly Detection with StatsForecast and PyMC, describes how to perform anomaly detection. In the daily life of an analyst, you will be tasked, more often than not, with finding anomalies before they create business impact. You will also have to understand how to deal with low-frequency data and derive anomalies while avoiding false positives.
Chapter 7
, Customer Insights – Segmentation and RFM, helps us discover how to segment customers and create valuable profiles for better marketing. We’ll explore customer segmentation and RFM scoring.
Chapter 8
, Customer Lifetime Value with PyMC Marketing, builds upon the previous chapter by showing how to assign a value to our customers and segments to optimize our marketing efforts, and to evaluate the ROI of our activities by estimating how much customers are worth.
Chapter 9
, Customer Survey Analysis, describes customer satisfaction analysis through surveys. Analyzing customer satisfaction is an integral part of customer satisfaction management, which is an important part of CRM. We’ll go through how to analyze survey data to derive insights, how to calculate samples, and the pitfalls of NPS.
Chapter 10
, Conjoint Analysis with pandas and Statsmodels, starts with a description of what conjoint analysis is and what it is used for. We’ll cover some of the techniques used to derive useful insights, customize your product offering with conjoint analysis, and explain how to build the analysis from the ground up.
Chapter 11
, Multi-Touch Digital Attribution, explains in detail what digital attribution is. Marketing attribution is a fundamental problem in marketing analytics. How to attribute outcomes to marketing channels will change the conclusions you derive from channel evaluation. This chapter will describe the most common attribution methods and how to build them.
Chapter 12
, Media Mix Modeling with PyMC Marketing, describes the fundamental issue of understanding how to use Media Mix Modeling to optimize your marketing activities. Understanding a marketing channel’s performance is important, but of critical importance in modern marketing analytics is understanding how channels interact with each other. The answer to this question allows us, as analysts, to advise marketing teams on optimal budget allocation.
Chapter 13
, Running Experiments with PyMC, starts by explaining the fundamentals of what an experiment is. Running experiments in marketing is a fundamental technique for optimization and efficiency. We’ll go through the fundamentals of how to run experiments and how to analyze the outcome, while avoiding the most common pitfalls.
To get the most out of this book
The code provided for this book comes in the form of Jupyter Notebooks, with the exception of Chapter 3
, which is a Python file. All chapters will teach you how to install the required packages for each section.
You should already have a Python distribution installed on your development machine, either via the main Python Website or using Anaconda. An alternative is to use Google Colab.
All source code was developed and tested on MacOS (64-bit) and Google Colab.
If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
Download the example code files
You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/Data-Analytics-for-Marketing
. If there’s an update to the code, it will be updated in the GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/
. Check them out!
Conventions used
There are a number of text conventions used throughout this book.
Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: To begin, we need to import the required libraries: streamlit, pandas, numpy, matplotlib, and seaborn.
A block of code is set as follows:
import pandas as pd
import numpy as np
import seaborn as sns
pd.set_option('display.float_format', lambda x: '%.2f' % x)
df = pd.read_csv('data/ trafficsources.csv')
df.describe()
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
# Define the model
with pm.Model() as model_pymc: alpha = 1.0/daily_sales.sales.mean() lambda_1 = pm.Exponential(lambda_1
, alpha) lambda_2 = pm.Exponential(lambda_2
, alpha)
Any command-line input or output is written as follows:
pip install tap-googleads
Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: Analytics can be split into four areas or pillars: descriptive, predictive, diagnostic, and prescriptive analytics.
Tips or important notes
Appear like this.
Get in touch
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, email us at [email protected]
and mention the book title in the subject of your message.
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata
and fill in the form.
Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected]
with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com
.
Share your thoughts
Once you’ve read Data Analytics for Marketing, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page
for this book and share your feedback.
Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.
Download a free PDF copy of this book
Thanks for purchasing this book!
Do you like to read on the go but are unable to carry your print books everywhere?
Is your eBook purchase not compatible with the device of your choice?
Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.
Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.
The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily
Follow these simple steps to get the benefits:
Scan the QR code or visit the link below
https://packt.link/free-ebook/9781803241609
2. Submit your proof of purchase
3. That’s it! We’ll send your free PDF and other benefits to your email directly
Part 1: Fundamentals of Analytics
In this part, we will go through the fundamentals of analytics, introducing marketing analytics as a discipline. We will be focusing on data extraction, ingestion, and exploratory data analysis, followed by techniques for effectively presenting results and building dashboards for non-technical audiences. The subsequent discussion shifts toward econometrics and causal inference, providing a foundational understanding of statistics and equipping you with the skills to construct, test, and evaluate statistical models, emphasizing their significance and application in marketing.
This part contains the following chapters:
Chapter 1
, What is Marketing Analytics?
Chapter 2
, Extracting and Exploring Data with Singer and pandas
Chapter 3
, Design Principles and Presenting Results with Streamlit
Chapter 4
, Econometrics and Causal Inference with Statsmodels and PyMC
1
What is Marketing Analytics?
Half the money I spend on advertising is wasted; the trouble is I don’t know which half.
– John Wanamaker, the forefather of marketing
In this chapter, we will attempt to cover the fundamentals of marketing analytics as a role and discipline. As a marketing analyst, you are faced with common questions during your day-to-day activities. For example, How did this campaign perform?
or How can you optimize your budget to achieve a result?
.
In this chapter, we will break down the types of analytics (from descriptive to prescriptive), the value they add to a business, and the questions each of them answers.
You will learn about the following topics:
What is analytics?
An overview of marketing analytics
Exploring different types of analytics
Beyond simple pivot tables
Why Python?
Modern challenges in the world of privacy-centric marketing
The importance of data engineering and tracking
By the end of this chapter, you will understand what marketing analytics is and what it is supposed to measure. You will have a firm grasp of the different types of analytics and why simply using a spreadsheet, while tempting, is sometimes not enough. You will also have an understanding of the importance of data engineering and web tracking.
But before we delve into the tools and techniques that are required of you, to achieve your results, we first need to unpack what we mean by analytics in general and marketing analytics in particular.
What is analytics?
Like any buzzword, analytics can often be overused and hard to define from an exact source. According to the Oxford Dictionary, the textbook definition of analytics is the systematic computational analysis of data or statistics, in order to describe, predict, and improve business performance
. Gartner defines it more broadly as statistical and mathematical data analysis that clusters, segments, scores, and predicts what scenarios are most likely to happen.
Analytics is commonly known to branch out into four pillars or areas: descriptive analytics, diagnostic analytics, predictive analytics, and prescriptive analytics.
In essence, analytics is the act of extracting meaningful and actionable insights from data by using a set of techniques and tools paired with domain knowledge. Raw data, however large it may be, will not be a silver bullet in your quest for insights in marketing. Neither will advanced techniques and a lack of domain knowledge of how the field you are analyzing operates. It is only in the joining of these three aspects—domain knowledge, data, and techniques—that you will be able to do your job.
An important caveat about analytics is that it is neither reporting nor data science. Your primary job is not to produce a stable, automatically updated dashboard or a machine learning pipeline. In analytics, it helps you to have the right mindset and try to achieve reproducible code for follow-up analysis, or have a stable pipeline. But as an analyst, that is not your primary goal; it is just nice to have in order to achieve your end result. Your primary goal is speed and accuracy; that is, you need to produce meaningful insights that teams easily rely on in a reasonable amount of time with reasonable accuracy.
While it may seem controversial, this distinction bears some thought. Often, analytics will be folded into one of the two extremes. Either it is viewed as simple reporting and/or BI work, meaning you will lose the ability to generate actionable insights due to the rigid nature of datasets and dashboard architecture required. Or, it is viewed as data science, which means you will often use complex models that require a lot of data to learn and are lacking in interpretability. Analytics stands in the middle, although with blurry frontiers:
Figure 1.1 – Business analytics as the intersection of several skillsFigure 1.1 – Business analytics as the intersection of several skills
Now let's gain an overview of what is marketing analytics.
An overview of marketing analytics
The quote at the beginning of this chapter illustrates one of the fundamental questions of the marketing manager in their day-to-day activities. The best way to evaluate where to spend and target their efforts to achieve their ultimate target is to obtain new customers or retain current ones.
Marketing analytics is nothing more than the application of analytical methods to said goal, bringing a quantifiable way of guiding investment or consumer targeting decisions. As with any new and growing domain, it is hard to pin an exact definition of it, but we can define it as a technology-enabled and model-supported approach to harness customer and market data to enhance marketing decision making
. Being a domain in the larger field of data analytics, it looks to use mathematics and statistics together with computational tools and techniques to find meaningful patterns and knowledge in data. In this book, we will strive to focus on only the most relevant techniques and models to solve fundamental questions in marketing analytics.
Standard techniques frequently used in marketing include media mix modeling, pricing and promotion analyses, sales force optimization, and customer analytics such as segmentation or lifetime value estimation. The optimization of websites and online campaigns now frequently works hand in hand with the more traditional marketing analysis techniques, coupled with attribution modeling and media mix modeling, to understand channel interactions and optimal budget allocation.
These tools and techniques will allow you to support both strategic marketing decisions—such as how much to spend on marketing and how to allocate budgets across a portfolio of brands and the marketing mix—and more tactical campaign support in terms of targeting the best potential customer with the optimal message in the most cost-effective medium at the ideal time.
The past decades have seen an explosion of data in a digital format, with some estimates pointing to a jump from 6 percent to around 90 percent. That, together with massive improvements in computational tools such as faster databases, inference algorithms, and easier programming languages for statistics means the dramatic improvement and evolution of marketing analytics in recent times. But one might wonder why we should be concerned with marketing analytics, or why it should be regarded as an independent sub-field of greater analytics.
Why should we bother with marketing analytics?
Any business that employs analytics, of any kind, expects that it will improve the performance of said business. Marketing analytics is no different. Evidence supports the claim that marketing analytics improves business performance, be it in the form of increased sales, profits, or market share.
One study states that for a one-unit increase in marketing analytics deployment (measured on a scale of 1–7), there is an increase of 8 percent in return on assets (ROA) for the business, accounting for $180 million in net income. Businesses in highly competitive industries gain even more; an increase of 21 percent on ROA.
Let’s see a simple example of what marketing analytics can do with a mail coupon campaign. Kroger, an American retailer, conducts regular direct mail coupon campaigns. These campaigns to customers delivered a redemption rate of 70 percent within six weeks of mailing compared to an average of 7.93 percent for other companies. How? According to the analytics company working with Kroger, Demographics can tell you nothing about it. Just because I am the same age as you, live next door, and have 2.2 children does not mean we have the same preferences.
What they do is study each customer to see what drives their behaviors individually. Do they have kids, do they skew toward healthy or fun, do they prefer organic or convenience foods, and where are they price sensitive? Is this across all products or only some? We tell our retailing customers there is no silver bullet. Take data from customers and look at the decisions the business is making and look at their impact on the consumer.
Having discussed the what and why of marketing analytics, we need to take a small detour to explain the different types of analytics in the analytical maturity model to better understand what to apply in each step.
Exploring different types of analytics
As we have seen earlier, analytics is a broad term covering four different pillars in the modern analytics ladder. Each plays a role in how your business can better understand what your data reveals and how you can use those insights to drive business objectives.
The following diagram will help you visualize how the pillars relate to one another:
Figure 1.2 – The analytics maturity modelFigure 1.2 – The analytics maturity model
The first step in the process is to always understand the fundamental questions you are trying to answer. All analytical questions can be boiled down into the following categories:
What happened and when did it happen?
Why and how did it happen?
What will happen in the future?
How can I make something happen?
These categories will define the different areas of analytics involved, which will inform our decision about what tooling and techniques to apply.
Analytics can be split into four areas or pillars: descriptive, predictive, diagnostic, and prescriptive analytics.
You can think of the pillars by remembering