Introduction to marketr

Introduction to marketr

marketr facilitates tidy calculation of popular quantitative marketing metrics (like Customer Experience Index and Net Promoter Score). By “tidy”, I am referring to the usage of the tidyverse packages and methodology for organizing and analyzing data. The package is designed so that beginning R users can calculate these metrics, along many dimensions, without needing to learn much R syntax. It is also helpful for more experienced programmers to do these calculations quickly.

Generate survey response data

To demonstrate the basic usage I will create simulated survey response data. needs, ease and emotion are the columns that make up CXi; nps_question is used for NPS; grps and months will show how these metrics can be calculated along categorical features and/or trended over time.

library(marketr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(magrittr)
library(ggplot2)

needs <- sample(2:5, 1000, replace = T)
ease <- sample(2:5, 1000, replace = T)
emotion <- sample(2:5, 1000, replace = T)
nps_question <- sample(3:10, 1000, replace = T)
grps <- c("a", "b", "c")
months <- sample(1:12, 1000, replace = T)

survey_data <- tibble::as_tibble(cbind(needs, ease, emotion, nps_question, grps, months)) %>%
  mutate(month = as.numeric(months))
## Warning in cbind(needs, ease, emotion, nps_question, grps, months): number of
## rows of result is not a multiple of vector length (arg 5)
head(survey_data)
## # A tibble: 6 × 7
##   needs ease  emotion nps_question grps  months month
##   <chr> <chr> <chr>   <chr>        <chr> <chr>  <dbl>
## 1 2     4     3       10           a     9          9
## 2 2     3     2       7            b     1          1
## 3 4     3     2       10           c     1          1
## 4 2     3     3       10           a     5          5
## 5 2     5     3       8            b     9          9
## 6 3     3     3       6            c     9          9

Calculating CXi

Customer Experience Index (CXI) was developed by Forrester. Per Forrester, CXi “measures how successfully a company delivers customer experiences that create and sustain loyalty.”

It involves scoring three questions, each with a likert scale response, and then averaging those scores together. Below, four calculations are done using two different functions.

# Overall CXi
cxi_calc(survey_data) %>% knitr::kable()
cxi survey_count
25.16667 1000
## CXi by group
cxi_calc(survey_data, grps, cx_high = 4, cx_low = 2) %>% knitr::kable()
grps cxi survey_count
a 26.74651 334
b 24.62462 333
c 24.12412 333
# Overall CXi trend
cxi_trend(survey_data, month) %>% knitr::kable() 
avg_survey_ct min_survey_ct month cxi survey_count
83.33333 68 1 24.82993 98
83.33333 68 2 24.50980 68
83.33333 68 3 17.09402 78
83.33333 68 4 19.04762 98
83.33333 68 5 23.69478 83
83.33333 68 6 27.08333 80
83.33333 68 7 26.01626 82
83.33333 68 8 23.07692 78
83.33333 68 9 33.33333 87
83.33333 68 10 30.30303 77
83.33333 68 11 25.83333 80
83.33333 68 12 27.47253 91
# Overall CXi trend by group - plotted
cxi_trend(survey_data, month, grps, cx_high = 4, cx_low = 2, min_surveys = 1, avg_surveys = 0) %>% 
  ggplot(aes(x = month, y = cxi)) +
  geom_line() +
  facet_wrap(grps ~ ., nrow = 3)
## Joining with `by = join_by(grps)`
## Joining with `by = join_by(grps)`

Calculating NPS

Net Promoter Score (NPS) was originally developed by Fred Reichheld and now is owned by Bain Company and Satmetrix Systems. The Wikipedia page is another good source of information. According to Wikipedia it “is a management tool that can be used to gauge the loyalty of a firm’s customer relationships.”

The calculation requires a single question with a ten-point scale. Like CXi it is not difficult to do manually; the package enables deeper analysis.Below, four calculations are done using two different functions.

# Overall NPS
nps_calc(survey_data) %>% knitr::kable()
nps survey_count
-51.1 1000
## NPS by group
nps_calc(survey_data, grps) %>% knitr::kable()
grps nps survey_count
a -48.20359 334
b -49.24925 333
c -55.85586 333
# Overall NPS trend
nps_trend(survey_data, month) %>% knitr::kable()
avg_survey_ct min_survey_ct month nps survey_count
83.33333 68 1 -46.93878 98
83.33333 68 2 -55.88235 68
83.33333 68 3 -53.84615 78
83.33333 68 4 -51.02041 98
83.33333 68 5 -44.57831 83
83.33333 68 6 -40.00000 80
83.33333 68 7 -62.19512 82
83.33333 68 8 -51.28205 78
83.33333 68 9 -52.87356 87
83.33333 68 10 -44.15584 77
83.33333 68 11 -42.50000 80
83.33333 68 12 -67.03297 91
# Overall NPS trend by group - plotted
nps_trend(survey_data, month, grps, min_surveys = 1, avg_surveys = 0) %>% 
  ggplot(aes(x = month, y = nps)) +
  geom_line() +
  facet_wrap(grps ~ ., nrow = 3)
## Joining with `by = join_by(grps)`
## Joining with `by = join_by(grps)`