library(knitr)
library(tidyverse)
library(DT)
library(ggplot2)
Advertising metrics in Tableau calculations.
In tableau
Benchmarking Sources
Vendor <- c("Ad Words Search", "Ad Words Display", "Double Click Low Viewability", "Double Click High Viewability", "Facebook", "YouTube")
CTR <- c(2.2, 0.22, NA, NA, 0.73, .0056)
ClickRate <- c(NA, NA, 0.07, 0.14, NA, NA)
CPC <- c(1.74, 0.46, NA, NA, 1.06, NA)
AverageConversionRate <- c(NA, NA, NA, NA, .1358, NA)
CostPerAction <- c(NA, NA, NA, NA, 7.85, NA)
Benchmarks <- data.frame(Vendor, CTR, ClickRate, CPC, AverageConversionRate, CostPerAction)
kable(Benchmarks)
Vendor | CTR | ClickRate | CPC | AverageConversionRate | CostPerAction |
---|---|---|---|---|---|
Ad Words Search | 2.2000 | NA | 1.74 | NA | NA |
Ad Words Display | 0.2200 | NA | 0.46 | NA | NA |
Double Click Low Viewability | NA | 0.07 | NA | NA | NA |
Double Click High Viewability | NA | 0.14 | NA | NA | NA |
0.7300 | NA | 1.06 | 0.1358 | 7.85 | |
YouTube | 0.0056 | NA | NA | NA | NA |
Benchmarks
DoubleClick
DC <- read.csv("DoubleClick_2017-10-24.csv", header = T, stringsAsFactors = F)
DC <- DC %>% rename(SiteDCM = Site..DCM., ViewableImp = Active.View..Viewable.Impressions, ClickRate = Click.Rate) %>% select(Date, Ad, SiteDCM, Ad.Type, Creative, Clicks, Impressions, ClickRate, ViewableImp)
DC$Date <- as.Date(DC$Date, format = "%m/%d/%Y")
DC <- DC %>% mutate(Click.Rate = round(((Clicks/Impressions)*100), digits = 2)) %>% arrange(desc(ViewableImp))
The DoubleClick Data
datatable(DC, options = list(
columnDefs = list(list(className = 'dt-center', targets = 5)),
pageLength = 5,
hover = TRUE,
lengthMenu = c(5, 10, 15, 20)
))
We would like to see which ads perform best on DoubleClick sites.
DoubleClick data for the Week starting 10-24-2017 grouped by site and Ad Type.
DC1 <- DC %>% group_by(Date, SiteDCM, Ad.Type) %>% summarise(ClickRate = round(mean(ClickRate), digits = 2)) %>% filter(SiteDCM!="Bangor Daily News")
datatable(DC1, options = list(
columnDefs = list(list(className = 'dt-center', targets = 3)),
pageLength = 5,
hover = TRUE,
lengthMenu = c(5, 10, 15, 20)
))
Double Click
Looking at how the different sites perform against the benchmarks.
The benchmarks are demarcated by the horizontal black lines.
The benchmark line at Click Rate = 0.7 when all impressions are considered. When only the viewable impressions are used, the Click Rate benchmark = 0.14.
I have left the Bangor Daily News out of this plot because its clickrate is well above the benchmark and it overshadows the other sites.
Note the Maine Today and the doubleclick bid manager ads performed below goals this week.
ggplot(data=DC1, aes(x=Date, y=ClickRate, group=SiteDCM, color=SiteDCM)) +
geom_smooth(se = FALSE) + theme_bw() + geom_hline(yintercept = 0.14) + geom_hline(yintercept = 0.07) + theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))
Ad Type
There are 4 ad types, Should ask Chris if default falls into one of these categories.
ggplot(data=DC1, aes(x=Date, y=ClickRate, group=Ad.Type, color=Ad.Type)) +
geom_smooth(se = FALSE) + theme_bw() + geom_hline(yintercept = 0.14) + geom_hline(yintercept = 0.07) + theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))
ggplot(data=DC1, aes(x=SiteDCM, y=ClickRate, fill=Ad.Type)) +
geom_bar(stat="identity", position=position_dodge()) + theme(axis.text.x = element_text(angle = 45, vjust = 1, hjust = 1)) + geom_hline(yintercept = 0.14) + geom_hline(yintercept = 0.07) + theme_bw()
Creative
Do some ads get clicked more than others?
Creative <- DC %>% group_by(Date, Creative) %>% summarise(CR = mean(Click.Rate))
Creative1 <- Creative %>% filter(Creative != "USM_Nate_VIDEO")
Creative2 <- Creative1 %>% filter(Creative != "USM_Veronica_VIDEO")
Creative3 <- Creative2 %>% filter(Creative != "USMFY18_Lauren_30sec")
exclusions <- c("USM_Nate_VIDEO", "USM_Veronica_VIDEO", "USMFY18_Lauren_30sec")
matchExpression <- paste(exclusions, collapse = "|")
EverythingElse <- Creative %>% filter(grepl(matchExpression, Creative))
datatable(EverythingElse)
ggplot(Creative3, aes(x = Creative, y = CR)) + geom_bar(stat = "identity", fill = "darkblue") + geom_hline(yintercept = 0.14) + geom_hline(yintercept = 0.07) + facet_wrap(~Date, ncol = 1)+ theme_bw() + theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))
Which show most often?
Grouping by Ad, this table shows a summary of this weeks statistics.
DCTable <- DC %>% group_by(Ad) %>% summarise(Clicks = sum(Clicks), Impressions = sum(Impressions), ViewableImp = sum(ViewableImp)) %>% mutate(pctImpViewable = round(ViewableImp/Impressions, digits = 2), ClickRate = round(((Clicks/ViewableImp)*100), digits = 2), Difference = ClickRate - 0.14) %>% arrange(desc(Clicks))
DCTableExclusions <- DCTable %>% filter(ViewableImp == 0)
datatable(DCTableExclusions, options = list(
columnDefs = list(list(className = 'dt-center', targets = 5)),
pageLength = 5,
hover = TRUE,
lengthMenu = c(5, 10, 15, 20)
))
Click Rates for DoubleClick Ads can be seen here. However, it’s skewed by a handful of ads.
ggplot(DCTable, aes(x = Ad, y = ClickRate)) + geom_bar(stat = "identity", fill = "darkblue") + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))+ geom_hline(yintercept = 0.14) + geom_hline(yintercept = 0.07)
Ads skewing the DC report.
#To exclude
ToExclude <- c("Video_BDN_Veronica", "Video_BDN_Nate", "Video_BDN_Lauren", "640x640_Spotify_Tracker_Nate", "300x250_Pandora_Veronica", "300x250_Pandora_Nate", "300x250 Default Web Ad")
matchExpression1 <- paste(ToExclude, collapse = "|")
Exclusions <- DCTable %>% filter(grepl(matchExpression1, Ad))
unique(Exclusions$Ad)
[1] "640x640_Spotify_Tracker_Nate" "Video_BDN_Nate"
[3] "Video_BDN_Lauren" "Video_BDN_Veronica"
[5] "300x250 Default Web Ad" "300x250_Pandora_Nate"
[7] "300x250_Pandora_Veronica"
ggplot(Exclusions, aes(x = Ad, y = ClickRate)) + geom_bar(stat = "identity", fill = "darkblue") + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))+ geom_hline(yintercept = 0.14) + geom_hline(yintercept = 0.07) + scale_y_continuous(limits = c(0, 60))
Click Rate is calculated with this formula: __(Clicks/ViewableImp)*100__
Turns out that 4 of the Ads that are skewing the report, have no viewable impressions. They
This plot shows the Ad Click Rates of the remaining ads that are not skewing the report.
datatable(EverythingElse)
DCTable <- DCTable %>% filter(Ad!="Video_BDN_Veronica")
DCTable <- DCTable %>% filter(Ad!= "Video_BDN_Nate")
DCTable <- DCTable %>% filter(Ad!= "Video_BDN_Lauren")
DCTable <- DCTable %>% filter(Ad!= "640x640_Spotify_Tracker_Nate")
DCTable <- DCTable %>% filter(Ad!= "300x250_Pandora_Veronica")
DCTable <- DCTable %>% filter(Ad!= "300x250_Pandora_Nate")
DCTable <- DCTable %>% filter(Ad!= "300x250 Default Web Ad")
head(DCTable)
ggplot(DCTable, aes(x = Ad, y = ClickRate)) + geom_bar(stat = "identity", fill = "darkblue") + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))+ geom_hline(yintercept = 0.14) + geom_hline(yintercept = 0.07)
ggplot(EverythingElse, aes(x = Ad, y = ClickRate)) + geom_bar(stat = "identity", fill = "darkblue") + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))+ geom_hline(yintercept = 0.14) + geom_hline(yintercept = 0.07)
Error in FUN(X[[i]], ...) : object 'Ad' not found
FB <- read.csv("Facebook_2017-10-24.csv", header = T, stringsAsFactors = F)
FB$Date <- as.Date(FB$Date, format = "%m/%d/%Y")
head(FB)
datatable(FB, options = list(
columnDefs = list(list(className = 'dt-center', targets = 5)),
pageLength = 5,
hover = TRUE,
lengthMenu = c(5, 10, 15, 20)
))
names(FB)
[1] "Ad.Name" "Platform" "Placement" "Device"
[5] "Date" "AdSetName" "Audience" "TargetLocation"
[9] "Campaign.Name" "Reach" "Frequency" "Impressions"
[13] "Clicks.All." "UniqueClicks.All." "CTR.All." "UniqueCTR.All."
[17] "AmountSpent" "CPM" "CostPer1000Reached" "CPC.All."
[21] "Actions" "PeopleTakingAction" "Likes" "LinkClicks"
[25] "ViewPercentage" "ViewTime"
Impressions, Clicks(All), Unique Clicks (All), Amount Spent, CTR, Unique CTR, CPC, and CPM are the metrics that have been marked as the most informative.
In tableau
names(FB)
[1] "Ad.Name" "Platform" "Placement" "Device"
[5] "Date" "AdSetName" "Audience" "TargetLocation"
[9] "Campaign.Name" "Reach" "Frequency" "Impressions"
[13] "Clicks.All." "UniqueClicks.All." "CTR.All." "UniqueCTR.All."
[17] "AmountSpent" "CPM" "CostPer1000Reached" "CPC.All."
[21] "Actions" "PeopleTakingAction" "Likes" "LinkClicks"
[25] "ViewPercentage" "ViewTime"
FBBench <- FB %>% select(Date,Ad.Name, Placement, Platform, Audience, Clicks.All., UniqueClicks.All., CTR.All., UniqueCTR.All.,CPC.All., Impressions, Actions, AmountSpent, PeopleTakingAction) %>% mutate(CTR_BenchMk = 0.73, CTRDiff = CTR.All. - CTR_BenchMk, CPC_Bench = 1.06, CPCDiff = CPC_Bench - CPC.All., CPA = round((AmountSpent/Actions),2), CPA_Bench = 7.85, CPADiff = CPA_Bench-CPA)
head(FBBench)
Here is the CTR by Audience over time. The benchmark CTR is demarcated with a black line. The HS audience is the strongest.
ggplot(FBBench, aes(x = Date, y = CTR.All., group = Audience, color = Audience)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = 0.73)
The CPC Benchmark is $1.06. This plot shows what USM paid per click daily the week of 10-24-2017. Anything over the black line means we are performing worse than the benchmark. Here it looks like marketing to graduate students is costly.
ggplot(FBBench, aes(x = Date, y = CPC.All., group = Audience, color = Audience)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = 1.06)
Cost per Action: This is calculated by the amount spent/number of actions. This seems way off. We pay well below the benchmark.
ggplot(FBBench, aes(x = Date, y = , CPA, group = Audience, color = Audience)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = 7.85)
ggplot(FBBench, aes(x = Date, y = , PeopleTakingAction, group = Audience, color = Audience)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))
datatable(FB %>% group_by(Date,AdSetName, Platform, Placement) %>% summarise(Imp = sum(Impressions), Clicks = sum(Clicks.All.), UniqueClicks = sum(UniqueClicks.All.), UniqueCTR = round(mean(UniqueCTR.All.), 2), CPC = round(mean(CPC.All.), 2), CPM = round(mean(CPM), 2)), options = list(
columnDefs = list(list(className = 'dt-center', targets = 5)),
pageLength = 5,
hover = TRUE,
lengthMenu = c(5, 10, 15, 20)
))
Number of records
ggplot(FB, aes(x = Audience, fill = Platform))+ geom_bar() + theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + theme_bw()
Which audience clicks most per amout spent?
ClicksToSpent <- FB %>% group_by(Audience, Platform) %>% summarise(TotalSpent = sum(AmountSpent), Clicks = sum(Clicks.All.), Likes = sum(Likes)) %>% mutate(RatioClickToSpent = round(Clicks/TotalSpent, 2))
datatable(ClicksToSpent)
Here we look at number of clicks by audience, broken down by platform.
ggplot(ClicksToSpent, aes(x=Audience, y=Clicks, fill=Platform)) +
geom_bar(stat="identity", position=position_dodge(), fill = "darkblue") + theme_bw()
Here we see the ratio of clicks to the total amount spent on each audience, by each platform.
ggplot(ClicksToSpent, aes(x = Audience, y = RatioClickToSpent, fill=Platform)) +
geom_bar(stat="identity", position=position_dodge(), fill = "darkblue") + theme_bw()
names(FB)
[1] "Ad.Name" "Platform" "Placement" "Device"
[5] "Date" "AdSetName" "Audience" "TargetLocation"
[9] "Campaign.Name" "Reach" "Frequency" "Impressions"
[13] "Clicks.All." "UniqueClicks.All." "CTR.All." "UniqueCTR.All."
[17] "AmountSpent" "CPM" "CostPer1000Reached" "CPC.All."
[21] "Actions" "PeopleTakingAction" "Likes" "LinkClicks"
[25] "ViewPercentage" "ViewTime"
summary(FB)
Ad.Name Platform Placement Device
Length:540 Length:540 Length:540 Length:540
Class :character Class :character Class :character Class :character
Mode :character Mode :character Mode :character Mode :character
Date AdSetName Audience TargetLocation
Min. :2017-10-24 Length:540 Length:540 Length:540
1st Qu.:2017-10-25 Class :character Class :character Class :character
Median :2017-10-27 Mode :character Mode :character Mode :character
Mean :2017-10-26
3rd Qu.:2017-10-29
Max. :2017-10-30
Campaign.Name Reach Frequency Impressions Clicks.All.
Length:540 Min. : 1.0 Min. :1.000 Min. : 1.00 Min. : 0.000
Class :character 1st Qu.: 15.0 1st Qu.:1.000 1st Qu.: 16.75 1st Qu.: 0.000
Mode :character Median : 64.5 Median :1.032 Median : 72.50 Median : 0.000
Mean : 297.1 Mean :1.201 Mean : 367.81 Mean : 2.557
3rd Qu.: 466.0 3rd Qu.:1.183 3rd Qu.: 548.00 3rd Qu.: 2.000
Max. :3692.0 Max. :7.500 Max. :3943.00 Max. :51.000
UniqueClicks.All. CTR.All. UniqueCTR.All. AmountSpent
Min. : 0.000 Min. : 0.00 Min. : 0.0000 Min. : 0.000
1st Qu.: 0.000 1st Qu.: 0.00 1st Qu.: 0.0000 1st Qu.: 0.000
Median : 0.000 Median : 0.00 Median : 0.0000 Median : 0.275
Mean : 2.465 Mean : 0.52 Mean : 0.6187 Mean : 3.002
3rd Qu.: 2.000 3rd Qu.: 0.50 3rd Qu.: 0.5800 3rd Qu.: 4.140
Max. :46.000 Max. :33.33 Max. :33.3300 Max. :102.710
CPM CostPer1000Reached CPC.All. Actions
Min. : 0.000 Min. : 0.000 Min. : 0.0000 Min. : 0.000
1st Qu.: 0.000 1st Qu.: 0.000 1st Qu.: 0.0000 1st Qu.: 0.000
Median : 4.750 Median : 5.155 Median : 0.0000 Median : 0.000
Mean : 10.784 Mean : 11.664 Mean : 0.8845 Mean : 4.459
3rd Qu.: 9.283 3rd Qu.: 10.230 3rd Qu.: 0.8725 3rd Qu.: 3.000
Max. :1093.330 Max. :1093.330 Max. :13.4100 Max. :66.000
PeopleTakingAction Likes LinkClicks ViewPercentage ViewTime
Min. : 0.000 Min. :1.000 Min. : 1.000 Min. :0 Min. :0
1st Qu.: 0.000 1st Qu.:1.000 1st Qu.: 1.000 1st Qu.:0 1st Qu.:0
Median : 0.000 Median :1.000 Median : 3.000 Median :0 Median :0
Mean : 2.781 Mean :1.182 Mean : 8.783 Mean :0 Mean :0
3rd Qu.: 2.000 3rd Qu.:1.000 3rd Qu.:13.000 3rd Qu.:0 3rd Qu.:0
Max. :46.000 Max. :2.000 Max. :51.000 Max. :0 Max. :0
NA's :529 NA's :420
range(FB$Likes)
[1] NA NA
SEM/AdWords
AdWords <- read.csv("Adwords_2017-10-241.csv", header = T, stringsAsFactors = F)
Adwords <- AdWords %>% rename(Date = Day, CampaignType = Campaign.type, AdGroup = Ad.group, CPC = Avg..CPC, CPM = Avg..CPM, AvgCost = Avg..Cost, AvgPosition = Avg..position, BounceRate = Bounce.rate, PagesSession = Pages...session, AvgDuration = Avg..session.duration..seconds., NewSessions = X..new.sessions)
Adwords$Date <- as.Date(Adwords$Date, format = "%d-%b-%y")
datatable(Adwords, options = list(
columnDefs = list(list(className = 'dt-center', targets = 5)),
pageLength = 5,
hover = TRUE,
lengthMenu = c(5, 10, 15, 20)
))
The report in Tableau looks like this:
In tableau
Search
Adwords %>% group_by(CampaignType) %>% summarise(ClTh = round(mean(CTR), 2))
head(Adwords)
unique(Adwords$CampaignType)
[1] "Search" "Search Network w/ Display Select"
[3] "Video" "Display"
Search <- Adwords %>% filter(CampaignType == "Search")
Search <- Search %>% group_by(Date, Campaign) %>% summarise(CTRate = round(mean(CTR), 2), AvgCPC = round(mean(CPC), 2))
Search
Display <- Adwords %>% filter(CampaignType == "Display")
Display <- Display %>% group_by(Date, Campaign) %>% summarise(CTRate = round(mean(CTR), 2), AvgCPC = round(mean(CPC), 2))
Display
SearchDisplay <- Adwords %>% filter(CampaignType == "Search Network w/ Display Select")
Video <- Adwords %>% filter(CampaignType == "Video")
For Search, our overall performance is just above the benchmark.
ggplot(Search, aes(x = Date, y = CTRate)) + geom_smooth(se = FALSE, color = "darkblue") + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = .022) + scale_y_continuous(limits = c(0, 0.075))
Search CPC
Overall, CPC for Search, costs less than the benchmark, however, when looked at by campaign, the Doctoral, Transfer, and Graduate campaigns cost more than the benchmark. Undergrad, courses, and Online camapaigns are less expensive.
ggplot(Search, aes(x = Date, y = AvgCPC)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = 1.74) + scale_y_continuous(limits = c(0, 2))
Search
ggplot(Search, aes(x = Date, y = AvgCPC, group = Campaign, color = Campaign)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = 1.74) + scale_y_continuous(limits = c(0, 4))
When we breaks down the campaigns, we see varying performance over time.
ggplot(Search, aes(x = Date, y = CTRate, group = Campaign, color = Campaign)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = .022) + scale_y_continuous(limits = c(0, 0.075))
Just looking at Campaign CTR, Online, Gmail Test, and Courses are the lower performers using AdWords Search.
Search1 <- Search %>% group_by(Campaign) %>% summarise(CTR = round(mean(CTRate), 2))
ggplot(Search1, aes(x = Campaign, y = CTR)) + geom_bar(stat = "identity", fill = "darkblue") + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = .022)
Display
Benchmark is 0.22
In terms of Display, we are performing well in Adwords.
Display2CPC <- Display %>% group_by(Campaign) %>% summarise(CPC = round(mean(AvgCPC), 2))
Display2CPC
Display1CTR
Display1CTR <- Display %>% group_by(Campaign) %>% summarise(CTR = round(mean(CTRate), 2))
head(Display1CTR)
ggplot(Display1CTR, aes(x = Campaign, y = CTR)) + geom_bar(stat = "identity", fill = "darkblue") + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = .0022)
Display
AdWords CPC
head(Display)
ggplot(Display, aes(x = Date, y = AvgCPC)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = .46) + scale_y_continuous(limits = c(0, 2))
Search
ggplot(Display, aes(x = Date, y = AvgCPC, group = Campaign, color = Campaign)) + geom_smooth(se = FALSE) + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1)) + geom_hline(yintercept = 0.46) + scale_y_continuous(limits = c(0, 4))
datatable(Adwords, options = list(
columnDefs = list(list(className = 'dt-center', targets = 5)),
pageLength = 5,
hover = TRUE,
lengthMenu = c(5, 10, 15, 20)
))
library(chron)
GA <- read.csv("GoogleAnalytics_2017-10-24.csv", header = T, stringsAsFactors = F)
GA <- GA %>% mutate(MinutesOnPage = round(MinutesOnPage, 2))
head(GA)
#convert time, didn't work
#convert date
library(lubridate)
GA$Date <- ymd(GA$Date)
ggplot(GA, aes(x = Date, y = Unique.Pageviews))+ geom_smooth(se = FALSE) + theme_bw()
GAGroup <- GA %>% group_by(Date, Source) %>% summarise(Ave.Page.viewsDay = mean(Unique.Pageviews), AvgBounces = mean(Bounces) , bouncesToViews = Ave.Page.viewsDay/AvgBounces)
ggplot(GAGroup, aes(x = Date, y = bouncesToViews, group = Source, color = Source)) + geom_line() + theme_bw()+ theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust = 1))
rpivotTable(Adwords ,c("Campaign","CampaignType","Clicks","Impressions", "CTR", "CTC", "CPM"))