SlideShare a Scribd company logo
1 of 75
Download to read offline
Domino Data Lab webinar
Managing and Optimizing Facebook Ad Campaigns with R
Gergely Daroczi
@daroczig
March 9 2016
About me
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 4 / 59
When to Advertise on Facebook
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 5 / 59
When to Advertise on Facebook
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 6 / 59
CARD.com’s View of the World
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 7 / 59
CARD.com’s View of the World
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 8 / 59
Modern Marketing
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 9 / 59
Modern Advertising
Google knows what you are searching for
Amazon knows what you are in the market for
Facebook knows what you like
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 10 / 59
Modern Advertising
Google knows what you are searching for
devtools::install.github( jburkhardt/RAdwords )
Amazon knows what you are in the market for
NULL
Facebook knows what you like
devtools::install.github( cardcorp/fbRads )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 11 / 59
Modern Advertising
Google knows what you are searching for
devtools::install.github( jburkhardt/RAdwords )
Amazon knows what you are in the market for
NULL
Facebook knows what you like
devtools::install.github( cardcorp/fbRads )
This info can be is used to advertise to you . . .
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 11 / 59
Modern Advertising
Google knows what you are searching for
devtools::install.github( jburkhardt/RAdwords )
Amazon knows what you are in the market for
NULL
Facebook knows what you like
devtools::install.github( cardcorp/fbRads )
This info can be is used to advertise to you . . .
. . . without much privacy concerns. How?
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 11 / 59
When to Advertise on Facebook
Source: adparlor.com
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 12 / 59
Anatomy of a Facebook Ad Campaign
Source: Facebook Marketing API docs
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 13 / 59
Facebook Ad Campaign Changes
https://developers.facebook.com/docs/marketing-api/changelog
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 14 / 59
Facebook Ad Campaign Changes
new API version every 6 months
2014:
campaigns: start/end date, budget
ads: targeting, placement, creative
Ad Report Stats
2015:
campaigns [ campaign_group ]: start/end date
adset [ campaign ]: budget, targeting, placement
ads [ ad_group ]: creative
Insights API
2016:
Consistent naming between API and UI
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 15 / 59
Has anyone seen this?
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 16 / 59
Has anyone seen this?
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 17 / 59
Has anyone seen this?
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 18 / 59
Get R package developer e-mails
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 19 / 59
Get R package developer e-mails
> url <- http://cran.r-project.org/web/checks/check_summary.html
> packages <- XML::readHTMLTable(url, which = 2)
> mails <- sub( .*<(.*)> , 1 , packages$ Maintainer )
> mails <- sub( at , @ , mails)
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 20 / 59
Get R package developer e-mails
> url <- http://cran.r-project.org/web/checks/check_summary.html
> packages <- XML::readHTMLTable(url, which = 2)
> mails <- sub( .*<(.*)> , 1 , packages$ Maintainer )
> mails <- sub( at , @ , mails)
> tail(sort(table(mails)))
## edd@debian.org (35) # Dirk Eddelbuettel
## Kurt.Hornik@R-project.org (29) # Kurt Hornik
## myrmecocystus@gmail.com (24) # Scott Chamberlain
## maechler@stat.math.ethz.ch (24) # Martin Maechler
## pgilbert.ttv9z@ncf.ca (22) # Paul Gilbert
> length(unique(mails))
## 4023
> tail(sort(table(sub( .*@ , , mails))))
## gmail.com (1778)
## R-project.org (84)
## edu
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 20 / 59
Get R package developer e-mail addresses
28 % match: only 900 accounts for 6,000+ R packages
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 21 / 59
Get e-mails from [R-help]
Get the location of the archives:
> url <- https://stat.ethz.ch/pipermail/r-help/
We need RCurl for HTTPS:
> library(RCurl)
Get URL of all archive files:
> R.help.toc <- htmlParse(getURL(url))
> R.help.archives <- unlist(
+ xpathApply(R.help.toc, "//table//td[3]/a", xmlAttrs),
+ use.names = FALSE)
Download archive files:
> dir.create( r-help )
> for (f in R.help.archives)
+ download.file(url = paste0(url, f),
+ file.path( help-r , f), method = curl )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 22 / 59
Extract e-mail addresses from [R-help]
Regular expression matching date format in “From” lines:
> dateregex <- paste( [A-Za-z]{3} [A-Za-z]{3} [0-9]{1,2} ,
+ [0-9]{2}:[0-9]{2}:[0-9]{2} [0-9]{4} )
grep for lines matching the From field:
> mails <- system(paste0(
+ "zgrep -E ^From .* at .* ",
+ dateregex,
+ " ./help-r/*.txt.gz"),
+ intern = TRUE)
Extract e-mail addresses from these lines:
> mails <- sub( .*From , , mails)
> mails <- sub(paste0( [ ]* , dateregex, $ ), , mails)
> mails <- sub( at , @ , mails)
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 23 / 59
Verify e-mail addresses from [R-help]
> length(mails)
266449
> head(sort(table(mails), decreasing = TRUE))
ripley@stats.ox.ac.uk dwinsemius@comcast.net
8611 7064
ggrothendieck@gmail.com p.dalgaard@biostat.ku.dk
5386 3243
jholtman@gmail.com smartpink111@yahoo.com
3193 2999
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 24 / 59
Verify e-mail addresses from [R-help]
> grep( Brian( D)? Ripley , names(table(mails)), value = TRUE)
[1] "Brian D Ripley"
[2] "Brian D Ripley [mailto:ripley at stats.ox.ac.uk]"
[3] "Brian Ripley"
[4] "Brian Ripley <ripley at stats.ox.ac.uk>"
[5] "Prof Brian D Ripley"
[6] "Prof Brian D Ripley [mailto:ripley at stats.ox.ac.uk]"
[7] " Prof Brian D Ripley <ripley at stats.ox.ac.uk>"
[8] ""Prof Brian D Ripley" <ripley at stats.ox.ac.uk>"
[9] "Prof Brian D Ripley <ripley at stats.ox.ac.uk>"
[10] "Prof Brian Ripley"
[11] "Prof. Brian Ripley"
[12] "Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]"
[13] "Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] "
[14] " tProf Brian Ripley <ripley at stats.ox.ac.uk>"
[15] " Prof Brian Ripley <ripley at stats.ox.ac.uk>"
[16] ""Prof Brian Ripley" <ripley at stats.ox.ac.uk>"
[17] "Prof Brian Ripley<ripley at stats.ox.ac.uk>"
[18] "Prof Brian Ripley <ripley at stats.ox.ac.uk>"
[19] "Prof Brian Ripley [ripley at stats.ox.ac.uk]"
[20] "Prof Brian Ripley <ripley at toucan.stats>"
[21] "Professor Brian Ripley"
[22] "r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Be
[23] "r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.c
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 25 / 59
Verify e-mail addresses from [R-help]
> length(mails)
266449
> head(sort(table(mails), decreasing = TRUE))
ripley@stats.ox.ac.uk dwinsemius@comcast.net
8611 7064
ggrothendieck@gmail.com p.dalgaard@biostat.ku.dk
5386 3243
jholtman@gmail.com smartpink111@yahoo.com
3193 2999
> length(unique(mails))
29266
> 29266 > 4023
TRUE o/
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 26 / 59
Authenticate with the Facebook API
https://developers.facebook.com/apps/
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 27 / 59
Authenticate with the Facebook API
Create a token:
> library(httr)
> app <- oauth_app( facebook , your_app_id , your_app_secret )
> Sys.setenv( HTTR_SERVER_PORT = 1410/ )
> tkn <- oauth2.0_token(
+ oauth_endpoints( facebook ), app, scope = ads_management ,
+ type = application/x-www-form-urlencoded )
> tkn <- tkn$credentials$access_token
Save this secret token (never commit to git repository) and load it in any
later session:
> saveRDS(tkn, token.rds )
> tkn <- readRDS( token.rds )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 28 / 59
The fun begins!
Initialize connection to Facebook Marketing API:
> devtools::install_packages( cardcorp/fbRads )
> library(fbRads)
> fbad_init(fid, tkn)
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 29 / 59
Create custom audience
> aud_id <- fbad_create_audience(name = R-help posters ,
+ title = Unique e-mail addresses in R-help 1997-2015 )
Reading audience info:
> fbad_read_audience(audience_id = aud_id,
+ fields = approximate_count )
20
Adding e-mails to audience (be patient):
> fbad_add_audience(audience_id = aud_id,
+ schema = EMAIL , hashes = mails)
> fbad_read_audience(audience_id = aud_id,
+ fields = approximate_count )
8700
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 30 / 59
Create lookalike audiences
Load the number of attendees per country:
> url <- http://rapporter.net/custom/R-activity/data/Rstats_2015.csv
> library(data.table)
> RpC <- fread(url)
> conference_countries <- RpC[user_all > 0, ]
Create a lookalike audience for each country with at least one useR! conference attendee:
> aud_ids <- sapply(1:nrow(conference_countries), function(i) {
+
+ try(fbad_create_lookalike_audience(
+ name = paste( R-help posters in ,
+ conference_countries[i, NAME]),
+ origin_audience_id = aud_id,
+ ratio = 0.01,
+ country = toupper(conference_countries[i, ISO2C])))
+
+ Sys.sleep(20)
+
+ })
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 31 / 59
Read lookalike audiences
Get the approximate count of each lookalike audience:
> lookalikes[!is.na(audience),
+ size := fbad_read_audience(audience, approximate_count )[[1]],
+ by = country]
> lookalikes[!is.na(audience), c( country , size ), with = FALSE]
country size country size
1: Australia 173000 13: Ireland 32800
2: Austria 41500 14: Italy 336200
3: Belgium 72400 15: Latvia 7800
4: Brazil 1280400 16: Mexico 758100
5: Canada 253100 17: Netherlands 110900
6: Colombia 308200 18: New Zealand 34500
7: Faroe Islands 400 19: Norway 36500
8: France 392900 20: Singapore 257000
9: Germany 347700 21: Slovenia 11200
10: Greece 59900 22: Spain 284200
11: Hungary 61500 23: Switzerland 43100
12: India 2042000 24: United Kingdom 478700
25: United States 2483200
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 32 / 59
Create a campaign
> campaign <- fbad_create_campaign(
+ name = Promote the Domino Data Lab webinar ,
+ objective = LINK_CLICKS )
> fbad_read_campaign(id = campaign,
+ fields = c( id , buying_type , name , objective ))
$id
[1] "********"
$buying_type
[1] "AUCTION"
$campaign_group_status
[1] "ACTIVE"
$objective
[1] "NONE"
$name
[1] "Promote the Domino Data Lab webinar"
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 33 / 59
Define target for an adset
All valid lookalike audiences:
> target <- lookalikes[!is.na(audience)]
> setnames(target, c( name , id ))
The original R-help posters list:
> target <- rbind(target, list( R-help poster list , id1))
The original R package developers list:
> target <- rbind(target, list( R pkg developers list , id2))
Prepare JSON list:
> target <- list(custom_audiences = target)
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 34 / 59
Create an adset
This is where we define the target and budget:
> adset <- fbad_create_adset(
+ name = Promo budget for the Domino Data Lab webinar ,
+ campaign_id = campaign,
+ billing_event = IMPRESSIONS ,
+ optimization_goal = REACH ,
+ bid_amount = 5,
+ campaign_status = ACTIVE ,
+ lifetime_budget = 4200,
+ end_time = as.numeric(as.POSIXct( 2016-03-09 )),
+ targeting = target)
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 35 / 59
Upload image
Get an image for the ad:
> img <- Domino-fbRads-webinar.png
> download.file( https://www.dominodatalab.com/resource/webinar/fbRads/Header.jpg ,
Upload to Facebook:
> img <- fbad_create_image(img = img)
Take a note on the returned hash:
> str(img)
List of 3
$ filename: chr "Domino-fbRads-webinar.png"
$ hash : chr "0af72a03b5b91a7201718ec2f06513dd"
$ url : chr "https://scontent.xx.fbcdn.net/hads-xfp1/t45.1600-4/124089
> img <- img$hash
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 36 / 59
Create a creative
> url <- file.path( https://www.dominodatalab.com/resource/web
+ managing_optimizing_facebook_ad_campaigns_
> (creative <- fbad_create_creative(
+ name = How to create ads from R? ,
+ body = paste(
+ Free webinar on how to create, manage ,
+ and optimize Facebook ads from R ),
+ title = How to create ads from R? ,
+ object_url = url,
+ image_hash = img$hash))
[1] 6036679347163
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 37 / 59
Preview the creative
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 38 / 59
Create an ad
> ad <- fbad_create_ad(
+ name = An ad -- right from the R console ,
+ adset_id = adset,
+ creative = creative)
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 39 / 59
Scalability
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 40 / 59
A/B testing
> taglines <- c( How to manage ads from R? ,
+ How to optimize ads from R? )
> for (tagline in taglines) {
+
+ ## create creative
+ creative <- fbad_create_creative(
+ name = tagline,
+ body = paste(
+ Free webinar on how to create, manage ,
+ and optimize Facebook ads from R ),
+ title = tagline,
+ object_url = url,
+ image_hash = img$hash)
+
+ ## create ad
+ ad <- fbad_create_ad(
+ name = paste0(tagline),
+ campaign_id = adset,
+ creative = creative)
+
+ }
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 41 / 59
Performance metrics
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 42 / 59
Performance metrics
> fb_insights(target = campaign, level = adgroup ,
+ fields = toJSON(c( reach , impressions , clicks )))
reach impressions clicks date_start date_stop
1 16936 22369 119 2015-10-26 2015-11-02
2 7259 8318 29 2015-10-26 2015-11-02
3 19134 22539 63 2015-10-26 2015-11-02
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 43 / 59
Performance metrics
> fb_insights(target = campaign, level = adgroup ,
+ fields = toJSON(c( reach , impressions , clicks )))
reach impressions clicks date_start date_stop
1 16936 22369 119 2015-10-26 2015-11-02
2 7259 8318 29 2015-10-26 2015-11-02
3 19134 22539 63 2015-10-26 2015-11-02
> fb_insights(target = campaign, level = adgroup ,
+ fields = toJSON(c( adgroup_name , cpc , cpp )))
adgroup_name cpc date_start date_stop
1 Optimize ads 0.2344538 2015-10-26 2015-11-02
2 Manage ads 0.5031034 2015-10-26 2015-11-02
3 Create ads 0.4974603 2015-10-26 2015-11-02
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 43 / 59
Performance metrics
> power.prop.test(p1 = 97 / 15682, p2 = 15 / 6672, power = 0.5, sig.level = 0.05)
Two-sample comparison of proportions power calculation
n = 2081.102
p1 = 0.006185436
p2 = 0.002248201
sig.level = 0.05
power = 0.5
alternative = two.sided
NOTE: n is number in *each* group
> fisher.test(data.frame(B = c(97, 15682), A = c(15, 6672)), conf.int = FALSE)
Fisher s Exact Test for Count Data
data: data.frame(B = c(97, 15682), A = c(15, 6672))
p-value = 6.811e-05
alternative hypothesis: true odds ratio is not equal to 1
sample estimates:
odds ratio
2.751109
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 44 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = adgroup )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 45 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = adgroup )
Expected results:
$ adgroup_id : chr "..." "..." "..."
$ campaign_id : chr "..." "..." "..."
$ campaign_group_id : chr "..." "..." "..."
$ account_id : chr "..." "..." "..."
$ frequency : num 1.11 1.01 1.28
$ impressions : chr "431" "280" "2735"
$ reach : int 390 277 2140
$ cpc : num 0.188 0.3 0.243
$ cpm : num 2.18 3.21 1.07
$ cpp : num 2.41 3.25 1.36
$ ctr : num 1.16 1.071 0.439
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 45 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = adgroup )
Expected results:
$ adgroup_id : chr "..." "..." "..."
$ campaign_id : chr "..." "..." "..."
$ campaign_group_id : chr "..." "..." "..."
$ account_id : chr "..." "..." "..."
$ frequency : num 1.11 1.01 1.28
$ impressions : chr "431" "280" "2735"
$ reach : int 390 277 2140
$ cpc : num 0.188 0.3 0.243
$ cpm : num 2.18 3.21 1.07
$ cpp : num 2.41 3.25 1.36
$ ctr : num 1.16 1.071 0.439
Response:
Error in fb_insights(date_preset = "today", level = "adgroup") (from fb_insights.R#9
(#100) Param level must be one of {ad, adset, campaign, account}
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 45 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 46 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Expected results:
$ adgroup_id : chr "..." "..." "..."
$ campaign_id : chr "..." "..." "..."
$ campaign_group_id : chr "..." "..." "..."
$ account_id : chr "..." "..." "..."
$ frequency : num 1.11 1.01 1.28
$ impressions : chr "431" "280" "2735"
$ reach : int 390 277 2140
$ cpc : num 0.188 0.3 0.243
$ cpm : num 2.18 3.21 1.07
$ cpp : num 2.41 3.25 1.36
$ ctr : num 1.16 1.071 0.439
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 46 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Expected results:
$ adgroup_id : chr "..." "..." "..."
$ campaign_id : chr "..." "..." "..."
$ campaign_group_id : chr "..." "..." "..."
$ account_id : chr "..." "..." "..."
$ frequency : num 1.11 1.01 1.28
$ impressions : chr "431" "280" "2735"
$ reach : int 390 277 2140
$ cpc : num 0.188 0.3 0.243
$ cpm : num 2.18 3.21 1.07
$ cpp : num 2.41 3.25 1.36
$ ctr : num 1.16 1.071 0.439
Response:
Failed to connect to 2a03:2880:20:4f06:face:b00c:0:1: Network is unreachable
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 46 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 47 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Response:
Curl (52): Empty reply from server
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 47 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 48 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Response header:
{
"Vary":["Accept-Encoding"],
"Content-Type":["text/html"],
"X-FB-Debug":["..."],
"Date":["Thu, 24 Sep 2015 16:38:27 GMT"],
"Connection":["keep-alive"],
"Content-Length":["19"],
"status":["503"],
"statusMessage":["Service Unavailable"]
}
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 48 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 49 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Header:
{"Content-Type":["text/html; charset=utf-8"], ..., "status":["502"],
"statusMessage":["Error parsing server response"]}
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 49 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Header:
{"Content-Type":["text/html; charset=utf-8"], ..., "status":["502"],
"statusMessage":["Error parsing server response"]}
Response:
<!DOCTYPE html>
<html lang="en" id="facebook">
<head>
<title>Facebook | Error</title>
</head>
<body>
<h1 id="sorry">Sorry, something went wrong.</h1>
<p id="promise">We re working on it and we ll get it fixed as soon as we can.</p
</body>
</html>
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 49 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 50 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Header:
{"Content-Type":["application/json; charset=UTF-8"], ..., "status":["200"],
"statusMessage":["OK"]}
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 50 / 59
What Could Possibly Go Wrong?
Query sent to Facebook:
mystats <- fb_insights(date_preset = today , level = ad )
Header:
{"Content-Type":["application/json; charset=UTF-8"], ..., "status":["200"],
"statusMessage":["OK"]}
Response:
{
"id":["..."],
"account_id":["..."],
"time_ref":[...],
"async_status":["Job Failed"],
"async_percent_completion":[0]
}
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 50 / 59
What Could Possibly Go Wrong?
Possible issues with the API calls:
1 Network error (network is unreachable)
2 Curl error (52)
3 HTTP error (503)
4 JSON syntax error (HMTL)
5 Facebook API error message
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 51 / 59
Error handling
Possible issues with the API calls using fbRads from R :
1 Network error (network is unreachable)
2 Curl error (52)
3 HTTP error (503)
4 JSON syntax error (HMTL)
5 Facebook API error message
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 52 / 59
Error handling
> mystats <- fb_insights(date_preset = today , level = ad )
ERROR [2015-11-01 08:27:44] Possible network error: Empty reply from server
INFO [2015-11-01 08:28:14] Retrying query for the 1 st/nd/rd time
ERROR [2015-11-01 08:28:14] Possible network error: Empty reply from server
INFO [2015-11-01 08:28:44] Retrying query for the 2 st/nd/rd time
DEBUG [2015-11-01 08:28:44] Sync request failed, starting async request.
DEBUG [2015-11-01 08:28:45] *** Async Job Not Started (0%). Waiting 2 seconds...
DEBUG [2015-11-01 08:28:47] *** Async Job Started (0%). Waiting 10 seconds...
ERROR [2015-11-01 08:28:57] {"id":["***"],..., "async_status":["Job Failed"]}
INFO [2015-11-01 08:28:57] Retrying query for the 1 st/nd/rd time
DEBUG [2015-11-01 08:28:57] *** Async Job Not Started (0%). Waiting 2 seconds...
DEBUG [2015-11-01 08:29:00] *** Async Job Started (0%). Waiting 10 seconds...
DEBUG [2015-11-01 08:29:10] *** Async Job Running (17%). Waiting 7.5 seconds...
DEBUG [2015-11-01 08:29:17] *** Async Job Running (35%). Waiting 5.6 seconds...
DEBUG [2015-11-01 08:29:23] *** Async Job Running (53%). Waiting 4.2 seconds...
DEBUG [2015-11-01 08:29:28] *** Async Job Running (71%). Waiting 3.2 seconds...
DEBUG [2015-11-01 08:29:31] *** Async Job Running (71%). Waiting 15.8 seconds...
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 53 / 59
Support for async/batch queries
> mystats <- fb_insights(date_preset = today , level = ad )
DEBUG [2015-11-01 08:28:56] Sync request failed, starting async request.
DEBUG [2015-11-01 08:28:57] *** Async Job Not Started (0%). Waiting 2 seconds...
DEBUG [2015-11-01 08:29:00] *** Async Job Started (0%). Waiting 10 seconds...
DEBUG [2015-11-01 08:29:10] *** Async Job Running (17%). Waiting 7.5 seconds...
DEBUG [2015-11-01 08:29:17] *** Async Job Running (35%). Waiting 5.6 seconds...
DEBUG [2015-11-01 08:29:23] *** Async Job Running (53%). Waiting 4.2 seconds...
DEBUG [2015-11-01 08:29:28] *** Async Job Running (71%). Waiting 3.2 seconds...
DEBUG [2015-11-01 08:29:31] *** Async Job Running (71%). Waiting 15.8 seconds...
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 54 / 59
https://github.com/cardcorp/fbRads
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 55 / 59
Keyword-based targeting
## Number of R users on Facebook
> (fbr <- fbad_get_search(q = rstats , type = adinterest )[, c(1:3, 6)])
id name audience_size topic
1 6003212345926 R (programming language) 1602320 Lifestyle and culture
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 56 / 59
Keyword-based targeting
## Number of R users on Facebook
> (fbr <- fbad_get_search(q = rstats , type = adinterest )[, c(1:3, 6)])
id name audience_size topic
1 6003212345926 R (programming language) 1602320 Lifestyle and culture
## Number of programmers on Facebook
> fbprog <- fbad_get_search(q = programming language , type = adinterest )
> head(fbprog[order(fbprog$audience_size, decreasing = TRUE), ], 10)[, 1:3]
id name audience_size
1 6003030200185 Programming language 269482400
67 6003017204650 PHP 37701920
2 6003476678525 Boo (programming language) 31028180
68 6004131486306 C++ 26812460
69 6003215894612 Ajax (programming) 14547070
3 6003682002118 Python (programming language) 14286850
70 6003127967124 JavaScript 12124380
4 6002979703120 Ruby (programming language) 11146690
5 6003437022731 Java (programming language) 9547610
71 6003568029103 Object-oriented programming 9490910
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 56 / 59
Targeting overlaps
## US-based R users on Facebook
> fbad_reachestimate(targeting_spec = list(
+ geo_locations = list(countries = US ),
+ flexible_spec = list(list(
+ interests = data.frame(
+ id = fbr$id,
+ name = fbr$name)))))$users
[1] 200000
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 57 / 59
Targeting overlaps
## US-based R users on Facebook
> fbad_reachestimate(targeting_spec = list(
+ geo_locations = list(countries = US ),
+ flexible_spec = list(list(
+ interests = data.frame(
+ id = fbr$id,
+ name = fbr$name)))))$users
[1] 200000
> fbprog <- data.table(fbprog)[name %in% c(
+ R (programming language) ,
+ Python (programming language) ,
+ Java (programming language) )]
## US-based R, Python or Java users on Facebook
> fbad_reachestimate(targeting_spec = list(
+ geo_locations = list(countries = US ),
+ flexible_spec = list(list(
+ interests = data.frame(
+ id = fbprog$id,
+ name = fbprog$name)))))$users
[1] 1700000
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 57 / 59
Targeting overlaps
## US-based R, but non-Python or Java users on Facebook
> fbad_reachestimate(targeting_spec = list(
+ geo_locations = list(countries = US ),
+ flexible_spec = list(list(
+ interests = data.frame(id = fbr$id, name = fbr$name))),
+ exclusions = list(interests = data.frame(
+ id = fbprog$id[1:2],
+ name = fbprog$name[1:2]))))$users
[1] 190000
## US-based R, Python and Java users on Facebook
> fbad_reachestimate(targeting_spec = list(
+ geo_locations = list(countries = US ),
+ flexible_spec = list(
+ list(interests = data.frame(
+ id = fbprog$id[1],
+ name = fbprog$id[1])),
+ list(interests = data.frame(
+ id = fbprog$id[2],
+ name = fbprog$id[2])),
+ list(interests = data.frame(
+ id = fbprog$id[3],
+ name = fbprog$id[3])))))$users
[1] 5300
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 58 / 59
Targeting overlaps
Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 59 / 59

More Related Content

Viewers also liked

H2O World - Collaborative, Reproducible Research with H2O - Nick Elprin
H2O World - Collaborative, Reproducible Research with H2O - Nick ElprinH2O World - Collaborative, Reproducible Research with H2O - Nick Elprin
H2O World - Collaborative, Reproducible Research with H2O - Nick ElprinSri Ambati
 
OSGeo와 Open Data
OSGeo와 Open DataOSGeo와 Open Data
OSGeo와 Open Datar-kor
 
황성수 공공데이터 개방과 공공이슈 해결
황성수 공공데이터 개방과 공공이슈 해결황성수 공공데이터 개방과 공공이슈 해결
황성수 공공데이터 개방과 공공이슈 해결r-kor
 
Distributed R: The Next Generation Platform for Predictive Analytics
Distributed R: The Next Generation Platform for Predictive AnalyticsDistributed R: The Next Generation Platform for Predictive Analytics
Distributed R: The Next Generation Platform for Predictive AnalyticsJorge Martinez de Salinas
 
Deciphering voice of customer through speech analytics
Deciphering voice of customer through speech analyticsDeciphering voice of customer through speech analytics
Deciphering voice of customer through speech analyticsR Systems International
 
Implementing a highly scalable stock prediction system with R, Geode, SpringX...
Implementing a highly scalable stock prediction system with R, Geode, SpringX...Implementing a highly scalable stock prediction system with R, Geode, SpringX...
Implementing a highly scalable stock prediction system with R, Geode, SpringX...William Markito Oliveira
 
Cloud Conf 2015 - Develop and Deploy IOT Applications
Cloud Conf 2015 - Develop and Deploy IOT ApplicationsCloud Conf 2015 - Develop and Deploy IOT Applications
Cloud Conf 2015 - Develop and Deploy IOT ApplicationsCorley S.r.l.
 
The Next List: R&D Breakthroughs that are Changing the World
The Next List: R&D Breakthroughs that are Changing the WorldThe Next List: R&D Breakthroughs that are Changing the World
The Next List: R&D Breakthroughs that are Changing the WorldGE
 
IMCSummit 2015 - Day 2 Developer Track - Implementing a Highly Scalable In-Me...
IMCSummit 2015 - Day 2 Developer Track - Implementing a Highly Scalable In-Me...IMCSummit 2015 - Day 2 Developer Track - Implementing a Highly Scalable In-Me...
IMCSummit 2015 - Day 2 Developer Track - Implementing a Highly Scalable In-Me...In-Memory Computing Summit
 
오픈데이터와 오픈소스 소프트웨어를 이용한 의료이용정보의 시각화
오픈데이터와 오픈소스 소프트웨어를 이용한 의료이용정보의 시각화오픈데이터와 오픈소스 소프트웨어를 이용한 의료이용정보의 시각화
오픈데이터와 오픈소스 소프트웨어를 이용한 의료이용정보의 시각화r-kor
 
구조화된 데이터: Schema.org와 Microdata, RDFa, JSON-LD
구조화된 데이터: Schema.org와 Microdata, RDFa, JSON-LD구조화된 데이터: Schema.org와 Microdata, RDFa, JSON-LD
구조화된 데이터: Schema.org와 Microdata, RDFa, JSON-LDr-kor
 
Trading System Design
Trading System DesignTrading System Design
Trading System DesignMarketcalls
 
Trading sentimental analysis
Trading sentimental analysisTrading sentimental analysis
Trading sentimental analysisMarketcalls
 
II-SDV 2016 Patrick Beaucamp - Data Science with R and Vanilla Air
II-SDV 2016 Patrick Beaucamp - Data Science with R and Vanilla AirII-SDV 2016 Patrick Beaucamp - Data Science with R and Vanilla Air
II-SDV 2016 Patrick Beaucamp - Data Science with R and Vanilla AirDr. Haxel Consult
 
Taking R Analytics to SQL and the Cloud
Taking R Analytics to SQL and the CloudTaking R Analytics to SQL and the Cloud
Taking R Analytics to SQL and the CloudRevolution Analytics
 
H2O World - Intro to R, Python, and Flow - Amy Wang
H2O World - Intro to R, Python, and Flow - Amy WangH2O World - Intro to R, Python, and Flow - Amy Wang
H2O World - Intro to R, Python, and Flow - Amy WangSri Ambati
 
Big data analysis with R and Apache Tajo (in Korean)
Big data analysis with R and Apache Tajo (in Korean)Big data analysis with R and Apache Tajo (in Korean)
Big data analysis with R and Apache Tajo (in Korean)Gruter
 
Introduction to R for Data Science :: Session 4
Introduction to R for Data Science :: Session 4Introduction to R for Data Science :: Session 4
Introduction to R for Data Science :: Session 4Goran S. Milovanovic
 

Viewers also liked (20)

H2O World - Collaborative, Reproducible Research with H2O - Nick Elprin
H2O World - Collaborative, Reproducible Research with H2O - Nick ElprinH2O World - Collaborative, Reproducible Research with H2O - Nick Elprin
H2O World - Collaborative, Reproducible Research with H2O - Nick Elprin
 
OSGeo와 Open Data
OSGeo와 Open DataOSGeo와 Open Data
OSGeo와 Open Data
 
황성수 공공데이터 개방과 공공이슈 해결
황성수 공공데이터 개방과 공공이슈 해결황성수 공공데이터 개방과 공공이슈 해결
황성수 공공데이터 개방과 공공이슈 해결
 
Distributed R: The Next Generation Platform for Predictive Analytics
Distributed R: The Next Generation Platform for Predictive AnalyticsDistributed R: The Next Generation Platform for Predictive Analytics
Distributed R: The Next Generation Platform for Predictive Analytics
 
Deciphering voice of customer through speech analytics
Deciphering voice of customer through speech analyticsDeciphering voice of customer through speech analytics
Deciphering voice of customer through speech analytics
 
Implementing a highly scalable stock prediction system with R, Geode, SpringX...
Implementing a highly scalable stock prediction system with R, Geode, SpringX...Implementing a highly scalable stock prediction system with R, Geode, SpringX...
Implementing a highly scalable stock prediction system with R, Geode, SpringX...
 
Cloud Conf 2015 - Develop and Deploy IOT Applications
Cloud Conf 2015 - Develop and Deploy IOT ApplicationsCloud Conf 2015 - Develop and Deploy IOT Applications
Cloud Conf 2015 - Develop and Deploy IOT Applications
 
R lecture oga
R lecture ogaR lecture oga
R lecture oga
 
The Next List: R&D Breakthroughs that are Changing the World
The Next List: R&D Breakthroughs that are Changing the WorldThe Next List: R&D Breakthroughs that are Changing the World
The Next List: R&D Breakthroughs that are Changing the World
 
IMCSummit 2015 - Day 2 Developer Track - Implementing a Highly Scalable In-Me...
IMCSummit 2015 - Day 2 Developer Track - Implementing a Highly Scalable In-Me...IMCSummit 2015 - Day 2 Developer Track - Implementing a Highly Scalable In-Me...
IMCSummit 2015 - Day 2 Developer Track - Implementing a Highly Scalable In-Me...
 
오픈데이터와 오픈소스 소프트웨어를 이용한 의료이용정보의 시각화
오픈데이터와 오픈소스 소프트웨어를 이용한 의료이용정보의 시각화오픈데이터와 오픈소스 소프트웨어를 이용한 의료이용정보의 시각화
오픈데이터와 오픈소스 소프트웨어를 이용한 의료이용정보의 시각화
 
구조화된 데이터: Schema.org와 Microdata, RDFa, JSON-LD
구조화된 데이터: Schema.org와 Microdata, RDFa, JSON-LD구조화된 데이터: Schema.org와 Microdata, RDFa, JSON-LD
구조화된 데이터: Schema.org와 Microdata, RDFa, JSON-LD
 
Trading System Design
Trading System DesignTrading System Design
Trading System Design
 
Trading sentimental analysis
Trading sentimental analysisTrading sentimental analysis
Trading sentimental analysis
 
II-SDV 2016 Patrick Beaucamp - Data Science with R and Vanilla Air
II-SDV 2016 Patrick Beaucamp - Data Science with R and Vanilla AirII-SDV 2016 Patrick Beaucamp - Data Science with R and Vanilla Air
II-SDV 2016 Patrick Beaucamp - Data Science with R and Vanilla Air
 
Language R
Language RLanguage R
Language R
 
Taking R Analytics to SQL and the Cloud
Taking R Analytics to SQL and the CloudTaking R Analytics to SQL and the Cloud
Taking R Analytics to SQL and the Cloud
 
H2O World - Intro to R, Python, and Flow - Amy Wang
H2O World - Intro to R, Python, and Flow - Amy WangH2O World - Intro to R, Python, and Flow - Amy Wang
H2O World - Intro to R, Python, and Flow - Amy Wang
 
Big data analysis with R and Apache Tajo (in Korean)
Big data analysis with R and Apache Tajo (in Korean)Big data analysis with R and Apache Tajo (in Korean)
Big data analysis with R and Apache Tajo (in Korean)
 
Introduction to R for Data Science :: Session 4
Introduction to R for Data Science :: Session 4Introduction to R for Data Science :: Session 4
Introduction to R for Data Science :: Session 4
 

Similar to Optimizing Facebook Campaigns with R

ランチタイム共有サービス 昼会 @ appengine ja night 18
ランチタイム共有サービス 昼会 @ appengine ja night 18ランチタイム共有サービス 昼会 @ appengine ja night 18
ランチタイム共有サービス 昼会 @ appengine ja night 18Mitsuhiro Setoguchi
 
Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Codemotion
 
DroidKaigi 2018報告会(公式アプリへのコントリビュート)
DroidKaigi 2018報告会(公式アプリへのコントリビュート)DroidKaigi 2018報告会(公式アプリへのコントリビュート)
DroidKaigi 2018報告会(公式アプリへのコントリビュート)Hironytic
 
A Gentle Introduction to Tidy Statistics in R.pdf
A Gentle Introduction to Tidy Statistics in R.pdfA Gentle Introduction to Tidy Statistics in R.pdf
A Gentle Introduction to Tidy Statistics in R.pdfVickyAlers
 
Buildingplatforms
BuildingplatformsBuildingplatforms
Buildingplatformscodebits
 
Tech Resources for Artist Seminar
Tech Resources for Artist SeminarTech Resources for Artist Seminar
Tech Resources for Artist SeminarKate Bladow
 
Social Media Mining using R
Social Media Mining using RSocial Media Mining using R
Social Media Mining using RSubhankar Mishra
 
Bootstrapping Tools and Practices
Bootstrapping Tools and PracticesBootstrapping Tools and Practices
Bootstrapping Tools and PracticesCliff McKinney
 
SearchLove London 2019 - Will Critchlow - Misunderstood Concepts at the Heart...
SearchLove London 2019 - Will Critchlow - Misunderstood Concepts at the Heart...SearchLove London 2019 - Will Critchlow - Misunderstood Concepts at the Heart...
SearchLove London 2019 - Will Critchlow - Misunderstood Concepts at the Heart...Distilled
 
Measuring Software development with GrimoireLab
Measuring Software development with GrimoireLabMeasuring Software development with GrimoireLab
Measuring Software development with GrimoireLabValerio Cosentino
 
Beyond open data: empowering citizens to understand their cities
Beyond open data: empowering citizens to understand their citiesBeyond open data: empowering citizens to understand their cities
Beyond open data: empowering citizens to understand their citiesmysociety
 
Data Visualizations with ggplot2
Data Visualizations with ggplot2Data Visualizations with ggplot2
Data Visualizations with ggplot2Ryan Harrington
 
The Future of Sharding
The Future of ShardingThe Future of Sharding
The Future of ShardingEDB
 
Digital marketing notes
Digital marketing notesDigital marketing notes
Digital marketing notesDipak Londhe
 
Scaling business app development with Play and Scala
Scaling business app development with Play and ScalaScaling business app development with Play and Scala
Scaling business app development with Play and ScalaPeter Hilton
 

Similar to Optimizing Facebook Campaigns with R (20)

ランチタイム共有サービス 昼会 @ appengine ja night 18
ランチタイム共有サービス 昼会 @ appengine ja night 18ランチタイム共有サービス 昼会 @ appengine ja night 18
ランチタイム共有サービス 昼会 @ appengine ja night 18
 
Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017Getting started with Go - Florin Patan - Codemotion Rome 2017
Getting started with Go - Florin Patan - Codemotion Rome 2017
 
Evolution and AI
Evolution and AIEvolution and AI
Evolution and AI
 
Git Started!
Git Started!Git Started!
Git Started!
 
DroidKaigi 2018報告会(公式アプリへのコントリビュート)
DroidKaigi 2018報告会(公式アプリへのコントリビュート)DroidKaigi 2018報告会(公式アプリへのコントリビュート)
DroidKaigi 2018報告会(公式アプリへのコントリビュート)
 
A Gentle Introduction to Tidy Statistics in R.pdf
A Gentle Introduction to Tidy Statistics in R.pdfA Gentle Introduction to Tidy Statistics in R.pdf
A Gentle Introduction to Tidy Statistics in R.pdf
 
Buildingplatforms
BuildingplatformsBuildingplatforms
Buildingplatforms
 
Tech Resources for Artist Seminar
Tech Resources for Artist SeminarTech Resources for Artist Seminar
Tech Resources for Artist Seminar
 
The state of curl 2022
The state of curl 2022The state of curl 2022
The state of curl 2022
 
Tech thursdays / GIT
Tech thursdays / GITTech thursdays / GIT
Tech thursdays / GIT
 
Social Media Mining using R
Social Media Mining using RSocial Media Mining using R
Social Media Mining using R
 
Bootstrapping Tools and Practices
Bootstrapping Tools and PracticesBootstrapping Tools and Practices
Bootstrapping Tools and Practices
 
SearchLove London 2019 - Will Critchlow - Misunderstood Concepts at the Heart...
SearchLove London 2019 - Will Critchlow - Misunderstood Concepts at the Heart...SearchLove London 2019 - Will Critchlow - Misunderstood Concepts at the Heart...
SearchLove London 2019 - Will Critchlow - Misunderstood Concepts at the Heart...
 
Measuring Software development with GrimoireLab
Measuring Software development with GrimoireLabMeasuring Software development with GrimoireLab
Measuring Software development with GrimoireLab
 
Beyond open data: empowering citizens to understand their cities
Beyond open data: empowering citizens to understand their citiesBeyond open data: empowering citizens to understand their cities
Beyond open data: empowering citizens to understand their cities
 
Data Visualizations with ggplot2
Data Visualizations with ggplot2Data Visualizations with ggplot2
Data Visualizations with ggplot2
 
SFScon 2020 - Matteo Ghetta - DataPlotly - D3-like plots in QGIS
SFScon 2020 - Matteo Ghetta - DataPlotly - D3-like plots in QGISSFScon 2020 - Matteo Ghetta - DataPlotly - D3-like plots in QGIS
SFScon 2020 - Matteo Ghetta - DataPlotly - D3-like plots in QGIS
 
The Future of Sharding
The Future of ShardingThe Future of Sharding
The Future of Sharding
 
Digital marketing notes
Digital marketing notesDigital marketing notes
Digital marketing notes
 
Scaling business app development with Play and Scala
Scaling business app development with Play and ScalaScaling business app development with Play and Scala
Scaling business app development with Play and Scala
 

More from Domino Data Lab

What's in your workflow? Bringing data science workflows to business analysis...
What's in your workflow? Bringing data science workflows to business analysis...What's in your workflow? Bringing data science workflows to business analysis...
What's in your workflow? Bringing data science workflows to business analysis...Domino Data Lab
 
The Proliferation of New Database Technologies and Implications for Data Scie...
The Proliferation of New Database Technologies and Implications for Data Scie...The Proliferation of New Database Technologies and Implications for Data Scie...
The Proliferation of New Database Technologies and Implications for Data Scie...Domino Data Lab
 
Racial Bias in Policing: an analysis of Illinois traffic stops data
Racial Bias in Policing: an analysis of Illinois traffic stops dataRacial Bias in Policing: an analysis of Illinois traffic stops data
Racial Bias in Policing: an analysis of Illinois traffic stops dataDomino Data Lab
 
Data Quality Analytics: Understanding what is in your data, before using it
Data Quality Analytics: Understanding what is in your data, before using itData Quality Analytics: Understanding what is in your data, before using it
Data Quality Analytics: Understanding what is in your data, before using itDomino Data Lab
 
Supporting innovation in insurance with randomized experimentation
Supporting innovation in insurance with randomized experimentationSupporting innovation in insurance with randomized experimentation
Supporting innovation in insurance with randomized experimentationDomino Data Lab
 
Leveraging Data Science in the Automotive Industry
Leveraging Data Science in the Automotive IndustryLeveraging Data Science in the Automotive Industry
Leveraging Data Science in the Automotive IndustryDomino Data Lab
 
Summertime Analytics: Predicting E. coli and West Nile Virus
Summertime Analytics: Predicting E. coli and West Nile VirusSummertime Analytics: Predicting E. coli and West Nile Virus
Summertime Analytics: Predicting E. coli and West Nile VirusDomino Data Lab
 
Reproducible Dashboards and other great things to do with Jupyter
Reproducible Dashboards and other great things to do with JupyterReproducible Dashboards and other great things to do with Jupyter
Reproducible Dashboards and other great things to do with JupyterDomino Data Lab
 
GeoViz: A Canvas for Data Science
GeoViz: A Canvas for Data ScienceGeoViz: A Canvas for Data Science
GeoViz: A Canvas for Data ScienceDomino Data Lab
 
Managing Data Science | Lessons from the Field
Managing Data Science | Lessons from the Field Managing Data Science | Lessons from the Field
Managing Data Science | Lessons from the Field Domino Data Lab
 
Doing your first Kaggle (Python for Big Data sets)
Doing your first Kaggle (Python for Big Data sets)Doing your first Kaggle (Python for Big Data sets)
Doing your first Kaggle (Python for Big Data sets)Domino Data Lab
 
Leveraged Analytics at Scale
Leveraged Analytics at ScaleLeveraged Analytics at Scale
Leveraged Analytics at ScaleDomino Data Lab
 
How I Learned to Stop Worrying and Love Linked Data
How I Learned to Stop Worrying and Love Linked DataHow I Learned to Stop Worrying and Love Linked Data
How I Learned to Stop Worrying and Love Linked DataDomino Data Lab
 
Software Engineering for Data Scientists
Software Engineering for Data ScientistsSoftware Engineering for Data Scientists
Software Engineering for Data ScientistsDomino Data Lab
 
Moving Data Science from an Event to A Program: Considerations in Creating Su...
Moving Data Science from an Event to A Program: Considerations in Creating Su...Moving Data Science from an Event to A Program: Considerations in Creating Su...
Moving Data Science from an Event to A Program: Considerations in Creating Su...Domino Data Lab
 
Building Data Analytics pipelines in the cloud using serverless technology
Building Data Analytics pipelines in the cloud using serverless technologyBuilding Data Analytics pipelines in the cloud using serverless technology
Building Data Analytics pipelines in the cloud using serverless technologyDomino Data Lab
 
Leveraging Open Source Automated Data Science Tools
Leveraging Open Source Automated Data Science ToolsLeveraging Open Source Automated Data Science Tools
Leveraging Open Source Automated Data Science ToolsDomino Data Lab
 
Domino and AWS: collaborative analytics and model governance at financial ser...
Domino and AWS: collaborative analytics and model governance at financial ser...Domino and AWS: collaborative analytics and model governance at financial ser...
Domino and AWS: collaborative analytics and model governance at financial ser...Domino Data Lab
 
The Role and Importance of Curiosity in Data Science
The Role and Importance of Curiosity in Data ScienceThe Role and Importance of Curiosity in Data Science
The Role and Importance of Curiosity in Data ScienceDomino Data Lab
 

More from Domino Data Lab (20)

What's in your workflow? Bringing data science workflows to business analysis...
What's in your workflow? Bringing data science workflows to business analysis...What's in your workflow? Bringing data science workflows to business analysis...
What's in your workflow? Bringing data science workflows to business analysis...
 
The Proliferation of New Database Technologies and Implications for Data Scie...
The Proliferation of New Database Technologies and Implications for Data Scie...The Proliferation of New Database Technologies and Implications for Data Scie...
The Proliferation of New Database Technologies and Implications for Data Scie...
 
Racial Bias in Policing: an analysis of Illinois traffic stops data
Racial Bias in Policing: an analysis of Illinois traffic stops dataRacial Bias in Policing: an analysis of Illinois traffic stops data
Racial Bias in Policing: an analysis of Illinois traffic stops data
 
Data Quality Analytics: Understanding what is in your data, before using it
Data Quality Analytics: Understanding what is in your data, before using itData Quality Analytics: Understanding what is in your data, before using it
Data Quality Analytics: Understanding what is in your data, before using it
 
Supporting innovation in insurance with randomized experimentation
Supporting innovation in insurance with randomized experimentationSupporting innovation in insurance with randomized experimentation
Supporting innovation in insurance with randomized experimentation
 
Leveraging Data Science in the Automotive Industry
Leveraging Data Science in the Automotive IndustryLeveraging Data Science in the Automotive Industry
Leveraging Data Science in the Automotive Industry
 
Summertime Analytics: Predicting E. coli and West Nile Virus
Summertime Analytics: Predicting E. coli and West Nile VirusSummertime Analytics: Predicting E. coli and West Nile Virus
Summertime Analytics: Predicting E. coli and West Nile Virus
 
Reproducible Dashboards and other great things to do with Jupyter
Reproducible Dashboards and other great things to do with JupyterReproducible Dashboards and other great things to do with Jupyter
Reproducible Dashboards and other great things to do with Jupyter
 
GeoViz: A Canvas for Data Science
GeoViz: A Canvas for Data ScienceGeoViz: A Canvas for Data Science
GeoViz: A Canvas for Data Science
 
Managing Data Science | Lessons from the Field
Managing Data Science | Lessons from the Field Managing Data Science | Lessons from the Field
Managing Data Science | Lessons from the Field
 
Doing your first Kaggle (Python for Big Data sets)
Doing your first Kaggle (Python for Big Data sets)Doing your first Kaggle (Python for Big Data sets)
Doing your first Kaggle (Python for Big Data sets)
 
Leveraged Analytics at Scale
Leveraged Analytics at ScaleLeveraged Analytics at Scale
Leveraged Analytics at Scale
 
How I Learned to Stop Worrying and Love Linked Data
How I Learned to Stop Worrying and Love Linked DataHow I Learned to Stop Worrying and Love Linked Data
How I Learned to Stop Worrying and Love Linked Data
 
Software Engineering for Data Scientists
Software Engineering for Data ScientistsSoftware Engineering for Data Scientists
Software Engineering for Data Scientists
 
Making Big Data Smart
Making Big Data SmartMaking Big Data Smart
Making Big Data Smart
 
Moving Data Science from an Event to A Program: Considerations in Creating Su...
Moving Data Science from an Event to A Program: Considerations in Creating Su...Moving Data Science from an Event to A Program: Considerations in Creating Su...
Moving Data Science from an Event to A Program: Considerations in Creating Su...
 
Building Data Analytics pipelines in the cloud using serverless technology
Building Data Analytics pipelines in the cloud using serverless technologyBuilding Data Analytics pipelines in the cloud using serverless technology
Building Data Analytics pipelines in the cloud using serverless technology
 
Leveraging Open Source Automated Data Science Tools
Leveraging Open Source Automated Data Science ToolsLeveraging Open Source Automated Data Science Tools
Leveraging Open Source Automated Data Science Tools
 
Domino and AWS: collaborative analytics and model governance at financial ser...
Domino and AWS: collaborative analytics and model governance at financial ser...Domino and AWS: collaborative analytics and model governance at financial ser...
Domino and AWS: collaborative analytics and model governance at financial ser...
 
The Role and Importance of Curiosity in Data Science
The Role and Importance of Curiosity in Data ScienceThe Role and Importance of Curiosity in Data Science
The Role and Importance of Curiosity in Data Science
 

Recently uploaded

5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteedamy56318795
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...SOFTTECHHUB
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...gajnagarg
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...nirzagarg
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制vexqp
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...HyderabadDolls
 
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...gragchanchal546
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...gajnagarg
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubaikojalkojal131
 
20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdfkhraisr
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样wsppdmt
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...HyderabadDolls
 
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...Health
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...gajnagarg
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabiaahmedjiabur940
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...kumargunjan9515
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxronsairoathenadugay
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.pptibrahimabdi22
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraGovindSinghDasila
 

Recently uploaded (20)

5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
TrafficWave Generator Will Instantly drive targeted and engaging traffic back...
 
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In dimapur [ 7014168258 ] Call Me For Genuine Models W...
 
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Satna [ 7014168258 ] Call Me For Genuine Models We ...
 
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
怎样办理圣地亚哥州立大学毕业证(SDSU毕业证书)成绩单学校原版复制
 
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
Jodhpur Park | Call Girls in Kolkata Phone No 8005736733 Elite Escort Service...
 
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
Gulbai Tekra * Cheap Call Girls In Ahmedabad Phone No 8005736733 Elite Escort...
 
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
Top profile Call Girls In Latur [ 7014168258 ] Call Me For Genuine Models We ...
 
Dubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls DubaiDubai Call Girls Peeing O525547819 Call Girls Dubai
Dubai Call Girls Peeing O525547819 Call Girls Dubai
 
20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf20240412-SmartCityIndex-2024-Full-Report.pdf
20240412-SmartCityIndex-2024-Full-Report.pdf
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
 
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
Nirala Nagar / Cheap Call Girls In Lucknow Phone No 9548273370 Elite Escort S...
 
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
+97470301568>>weed for sale in qatar ,weed for sale in dubai,weed for sale in...
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Indore [ 7014168258 ] Call Me For Genuine Models We...
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...Fun all Day Call Girls in Jaipur   9332606886  High Profile Call Girls You Ca...
Fun all Day Call Girls in Jaipur 9332606886 High Profile Call Girls You Ca...
 
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptxRESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
RESEARCH-FINAL-DEFENSE-PPT-TEMPLATE.pptx
 
7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt7. Epi of Chronic respiratory diseases.ppt
7. Epi of Chronic respiratory diseases.ppt
 
Aspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - AlmoraAspirational Block Program Block Syaldey District - Almora
Aspirational Block Program Block Syaldey District - Almora
 

Optimizing Facebook Campaigns with R

  • 1.
  • 2. Domino Data Lab webinar Managing and Optimizing Facebook Ad Campaigns with R Gergely Daroczi @daroczig March 9 2016
  • 3.
  • 4. About me Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 4 / 59
  • 5. When to Advertise on Facebook Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 5 / 59
  • 6. When to Advertise on Facebook Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 6 / 59
  • 7. CARD.com’s View of the World Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 7 / 59
  • 8. CARD.com’s View of the World Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 8 / 59
  • 9. Modern Marketing Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 9 / 59
  • 10. Modern Advertising Google knows what you are searching for Amazon knows what you are in the market for Facebook knows what you like Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 10 / 59
  • 11. Modern Advertising Google knows what you are searching for devtools::install.github( jburkhardt/RAdwords ) Amazon knows what you are in the market for NULL Facebook knows what you like devtools::install.github( cardcorp/fbRads ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 11 / 59
  • 12. Modern Advertising Google knows what you are searching for devtools::install.github( jburkhardt/RAdwords ) Amazon knows what you are in the market for NULL Facebook knows what you like devtools::install.github( cardcorp/fbRads ) This info can be is used to advertise to you . . . Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 11 / 59
  • 13. Modern Advertising Google knows what you are searching for devtools::install.github( jburkhardt/RAdwords ) Amazon knows what you are in the market for NULL Facebook knows what you like devtools::install.github( cardcorp/fbRads ) This info can be is used to advertise to you . . . . . . without much privacy concerns. How? Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 11 / 59
  • 14. When to Advertise on Facebook Source: adparlor.com Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 12 / 59
  • 15. Anatomy of a Facebook Ad Campaign Source: Facebook Marketing API docs Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 13 / 59
  • 16. Facebook Ad Campaign Changes https://developers.facebook.com/docs/marketing-api/changelog Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 14 / 59
  • 17. Facebook Ad Campaign Changes new API version every 6 months 2014: campaigns: start/end date, budget ads: targeting, placement, creative Ad Report Stats 2015: campaigns [ campaign_group ]: start/end date adset [ campaign ]: budget, targeting, placement ads [ ad_group ]: creative Insights API 2016: Consistent naming between API and UI Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 15 / 59
  • 18. Has anyone seen this? Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 16 / 59
  • 19. Has anyone seen this? Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 17 / 59
  • 20. Has anyone seen this? Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 18 / 59
  • 21. Get R package developer e-mails Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 19 / 59
  • 22. Get R package developer e-mails > url <- http://cran.r-project.org/web/checks/check_summary.html > packages <- XML::readHTMLTable(url, which = 2) > mails <- sub( .*<(.*)> , 1 , packages$ Maintainer ) > mails <- sub( at , @ , mails) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 20 / 59
  • 23. Get R package developer e-mails > url <- http://cran.r-project.org/web/checks/check_summary.html > packages <- XML::readHTMLTable(url, which = 2) > mails <- sub( .*<(.*)> , 1 , packages$ Maintainer ) > mails <- sub( at , @ , mails) > tail(sort(table(mails))) ## edd@debian.org (35) # Dirk Eddelbuettel ## Kurt.Hornik@R-project.org (29) # Kurt Hornik ## myrmecocystus@gmail.com (24) # Scott Chamberlain ## maechler@stat.math.ethz.ch (24) # Martin Maechler ## pgilbert.ttv9z@ncf.ca (22) # Paul Gilbert > length(unique(mails)) ## 4023 > tail(sort(table(sub( .*@ , , mails)))) ## gmail.com (1778) ## R-project.org (84) ## edu Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 20 / 59
  • 24. Get R package developer e-mail addresses 28 % match: only 900 accounts for 6,000+ R packages Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 21 / 59
  • 25. Get e-mails from [R-help] Get the location of the archives: > url <- https://stat.ethz.ch/pipermail/r-help/ We need RCurl for HTTPS: > library(RCurl) Get URL of all archive files: > R.help.toc <- htmlParse(getURL(url)) > R.help.archives <- unlist( + xpathApply(R.help.toc, "//table//td[3]/a", xmlAttrs), + use.names = FALSE) Download archive files: > dir.create( r-help ) > for (f in R.help.archives) + download.file(url = paste0(url, f), + file.path( help-r , f), method = curl ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 22 / 59
  • 26. Extract e-mail addresses from [R-help] Regular expression matching date format in “From” lines: > dateregex <- paste( [A-Za-z]{3} [A-Za-z]{3} [0-9]{1,2} , + [0-9]{2}:[0-9]{2}:[0-9]{2} [0-9]{4} ) grep for lines matching the From field: > mails <- system(paste0( + "zgrep -E ^From .* at .* ", + dateregex, + " ./help-r/*.txt.gz"), + intern = TRUE) Extract e-mail addresses from these lines: > mails <- sub( .*From , , mails) > mails <- sub(paste0( [ ]* , dateregex, $ ), , mails) > mails <- sub( at , @ , mails) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 23 / 59
  • 27. Verify e-mail addresses from [R-help] > length(mails) 266449 > head(sort(table(mails), decreasing = TRUE)) ripley@stats.ox.ac.uk dwinsemius@comcast.net 8611 7064 ggrothendieck@gmail.com p.dalgaard@biostat.ku.dk 5386 3243 jholtman@gmail.com smartpink111@yahoo.com 3193 2999 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 24 / 59
  • 28. Verify e-mail addresses from [R-help] > grep( Brian( D)? Ripley , names(table(mails)), value = TRUE) [1] "Brian D Ripley" [2] "Brian D Ripley [mailto:ripley at stats.ox.ac.uk]" [3] "Brian Ripley" [4] "Brian Ripley <ripley at stats.ox.ac.uk>" [5] "Prof Brian D Ripley" [6] "Prof Brian D Ripley [mailto:ripley at stats.ox.ac.uk]" [7] " Prof Brian D Ripley <ripley at stats.ox.ac.uk>" [8] ""Prof Brian D Ripley" <ripley at stats.ox.ac.uk>" [9] "Prof Brian D Ripley <ripley at stats.ox.ac.uk>" [10] "Prof Brian Ripley" [11] "Prof. Brian Ripley" [12] "Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]" [13] "Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] " [14] " tProf Brian Ripley <ripley at stats.ox.ac.uk>" [15] " Prof Brian Ripley <ripley at stats.ox.ac.uk>" [16] ""Prof Brian Ripley" <ripley at stats.ox.ac.uk>" [17] "Prof Brian Ripley<ripley at stats.ox.ac.uk>" [18] "Prof Brian Ripley <ripley at stats.ox.ac.uk>" [19] "Prof Brian Ripley [ripley at stats.ox.ac.uk]" [20] "Prof Brian Ripley <ripley at toucan.stats>" [21] "Professor Brian Ripley" [22] "r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Be [23] "r-help-bounces at stat.math.ethz.ch [mailto:r-help-bounces at stat.math.ethz.c Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 25 / 59
  • 29. Verify e-mail addresses from [R-help] > length(mails) 266449 > head(sort(table(mails), decreasing = TRUE)) ripley@stats.ox.ac.uk dwinsemius@comcast.net 8611 7064 ggrothendieck@gmail.com p.dalgaard@biostat.ku.dk 5386 3243 jholtman@gmail.com smartpink111@yahoo.com 3193 2999 > length(unique(mails)) 29266 > 29266 > 4023 TRUE o/ Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 26 / 59
  • 30. Authenticate with the Facebook API https://developers.facebook.com/apps/ Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 27 / 59
  • 31. Authenticate with the Facebook API Create a token: > library(httr) > app <- oauth_app( facebook , your_app_id , your_app_secret ) > Sys.setenv( HTTR_SERVER_PORT = 1410/ ) > tkn <- oauth2.0_token( + oauth_endpoints( facebook ), app, scope = ads_management , + type = application/x-www-form-urlencoded ) > tkn <- tkn$credentials$access_token Save this secret token (never commit to git repository) and load it in any later session: > saveRDS(tkn, token.rds ) > tkn <- readRDS( token.rds ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 28 / 59
  • 32. The fun begins! Initialize connection to Facebook Marketing API: > devtools::install_packages( cardcorp/fbRads ) > library(fbRads) > fbad_init(fid, tkn) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 29 / 59
  • 33. Create custom audience > aud_id <- fbad_create_audience(name = R-help posters , + title = Unique e-mail addresses in R-help 1997-2015 ) Reading audience info: > fbad_read_audience(audience_id = aud_id, + fields = approximate_count ) 20 Adding e-mails to audience (be patient): > fbad_add_audience(audience_id = aud_id, + schema = EMAIL , hashes = mails) > fbad_read_audience(audience_id = aud_id, + fields = approximate_count ) 8700 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 30 / 59
  • 34. Create lookalike audiences Load the number of attendees per country: > url <- http://rapporter.net/custom/R-activity/data/Rstats_2015.csv > library(data.table) > RpC <- fread(url) > conference_countries <- RpC[user_all > 0, ] Create a lookalike audience for each country with at least one useR! conference attendee: > aud_ids <- sapply(1:nrow(conference_countries), function(i) { + + try(fbad_create_lookalike_audience( + name = paste( R-help posters in , + conference_countries[i, NAME]), + origin_audience_id = aud_id, + ratio = 0.01, + country = toupper(conference_countries[i, ISO2C]))) + + Sys.sleep(20) + + }) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 31 / 59
  • 35. Read lookalike audiences Get the approximate count of each lookalike audience: > lookalikes[!is.na(audience), + size := fbad_read_audience(audience, approximate_count )[[1]], + by = country] > lookalikes[!is.na(audience), c( country , size ), with = FALSE] country size country size 1: Australia 173000 13: Ireland 32800 2: Austria 41500 14: Italy 336200 3: Belgium 72400 15: Latvia 7800 4: Brazil 1280400 16: Mexico 758100 5: Canada 253100 17: Netherlands 110900 6: Colombia 308200 18: New Zealand 34500 7: Faroe Islands 400 19: Norway 36500 8: France 392900 20: Singapore 257000 9: Germany 347700 21: Slovenia 11200 10: Greece 59900 22: Spain 284200 11: Hungary 61500 23: Switzerland 43100 12: India 2042000 24: United Kingdom 478700 25: United States 2483200 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 32 / 59
  • 36. Create a campaign > campaign <- fbad_create_campaign( + name = Promote the Domino Data Lab webinar , + objective = LINK_CLICKS ) > fbad_read_campaign(id = campaign, + fields = c( id , buying_type , name , objective )) $id [1] "********" $buying_type [1] "AUCTION" $campaign_group_status [1] "ACTIVE" $objective [1] "NONE" $name [1] "Promote the Domino Data Lab webinar" Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 33 / 59
  • 37. Define target for an adset All valid lookalike audiences: > target <- lookalikes[!is.na(audience)] > setnames(target, c( name , id )) The original R-help posters list: > target <- rbind(target, list( R-help poster list , id1)) The original R package developers list: > target <- rbind(target, list( R pkg developers list , id2)) Prepare JSON list: > target <- list(custom_audiences = target) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 34 / 59
  • 38. Create an adset This is where we define the target and budget: > adset <- fbad_create_adset( + name = Promo budget for the Domino Data Lab webinar , + campaign_id = campaign, + billing_event = IMPRESSIONS , + optimization_goal = REACH , + bid_amount = 5, + campaign_status = ACTIVE , + lifetime_budget = 4200, + end_time = as.numeric(as.POSIXct( 2016-03-09 )), + targeting = target) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 35 / 59
  • 39. Upload image Get an image for the ad: > img <- Domino-fbRads-webinar.png > download.file( https://www.dominodatalab.com/resource/webinar/fbRads/Header.jpg , Upload to Facebook: > img <- fbad_create_image(img = img) Take a note on the returned hash: > str(img) List of 3 $ filename: chr "Domino-fbRads-webinar.png" $ hash : chr "0af72a03b5b91a7201718ec2f06513dd" $ url : chr "https://scontent.xx.fbcdn.net/hads-xfp1/t45.1600-4/124089 > img <- img$hash Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 36 / 59
  • 40. Create a creative > url <- file.path( https://www.dominodatalab.com/resource/web + managing_optimizing_facebook_ad_campaigns_ > (creative <- fbad_create_creative( + name = How to create ads from R? , + body = paste( + Free webinar on how to create, manage , + and optimize Facebook ads from R ), + title = How to create ads from R? , + object_url = url, + image_hash = img$hash)) [1] 6036679347163 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 37 / 59
  • 41. Preview the creative Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 38 / 59
  • 42. Create an ad > ad <- fbad_create_ad( + name = An ad -- right from the R console , + adset_id = adset, + creative = creative) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 39 / 59
  • 43. Scalability Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 40 / 59
  • 44. A/B testing > taglines <- c( How to manage ads from R? , + How to optimize ads from R? ) > for (tagline in taglines) { + + ## create creative + creative <- fbad_create_creative( + name = tagline, + body = paste( + Free webinar on how to create, manage , + and optimize Facebook ads from R ), + title = tagline, + object_url = url, + image_hash = img$hash) + + ## create ad + ad <- fbad_create_ad( + name = paste0(tagline), + campaign_id = adset, + creative = creative) + + } Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 41 / 59
  • 45. Performance metrics Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 42 / 59
  • 46. Performance metrics > fb_insights(target = campaign, level = adgroup , + fields = toJSON(c( reach , impressions , clicks ))) reach impressions clicks date_start date_stop 1 16936 22369 119 2015-10-26 2015-11-02 2 7259 8318 29 2015-10-26 2015-11-02 3 19134 22539 63 2015-10-26 2015-11-02 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 43 / 59
  • 47. Performance metrics > fb_insights(target = campaign, level = adgroup , + fields = toJSON(c( reach , impressions , clicks ))) reach impressions clicks date_start date_stop 1 16936 22369 119 2015-10-26 2015-11-02 2 7259 8318 29 2015-10-26 2015-11-02 3 19134 22539 63 2015-10-26 2015-11-02 > fb_insights(target = campaign, level = adgroup , + fields = toJSON(c( adgroup_name , cpc , cpp ))) adgroup_name cpc date_start date_stop 1 Optimize ads 0.2344538 2015-10-26 2015-11-02 2 Manage ads 0.5031034 2015-10-26 2015-11-02 3 Create ads 0.4974603 2015-10-26 2015-11-02 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 43 / 59
  • 48. Performance metrics > power.prop.test(p1 = 97 / 15682, p2 = 15 / 6672, power = 0.5, sig.level = 0.05) Two-sample comparison of proportions power calculation n = 2081.102 p1 = 0.006185436 p2 = 0.002248201 sig.level = 0.05 power = 0.5 alternative = two.sided NOTE: n is number in *each* group > fisher.test(data.frame(B = c(97, 15682), A = c(15, 6672)), conf.int = FALSE) Fisher s Exact Test for Count Data data: data.frame(B = c(97, 15682), A = c(15, 6672)) p-value = 6.811e-05 alternative hypothesis: true odds ratio is not equal to 1 sample estimates: odds ratio 2.751109 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 44 / 59
  • 49. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = adgroup ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 45 / 59
  • 50. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = adgroup ) Expected results: $ adgroup_id : chr "..." "..." "..." $ campaign_id : chr "..." "..." "..." $ campaign_group_id : chr "..." "..." "..." $ account_id : chr "..." "..." "..." $ frequency : num 1.11 1.01 1.28 $ impressions : chr "431" "280" "2735" $ reach : int 390 277 2140 $ cpc : num 0.188 0.3 0.243 $ cpm : num 2.18 3.21 1.07 $ cpp : num 2.41 3.25 1.36 $ ctr : num 1.16 1.071 0.439 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 45 / 59
  • 51. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = adgroup ) Expected results: $ adgroup_id : chr "..." "..." "..." $ campaign_id : chr "..." "..." "..." $ campaign_group_id : chr "..." "..." "..." $ account_id : chr "..." "..." "..." $ frequency : num 1.11 1.01 1.28 $ impressions : chr "431" "280" "2735" $ reach : int 390 277 2140 $ cpc : num 0.188 0.3 0.243 $ cpm : num 2.18 3.21 1.07 $ cpp : num 2.41 3.25 1.36 $ ctr : num 1.16 1.071 0.439 Response: Error in fb_insights(date_preset = "today", level = "adgroup") (from fb_insights.R#9 (#100) Param level must be one of {ad, adset, campaign, account} Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 45 / 59
  • 52. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 46 / 59
  • 53. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Expected results: $ adgroup_id : chr "..." "..." "..." $ campaign_id : chr "..." "..." "..." $ campaign_group_id : chr "..." "..." "..." $ account_id : chr "..." "..." "..." $ frequency : num 1.11 1.01 1.28 $ impressions : chr "431" "280" "2735" $ reach : int 390 277 2140 $ cpc : num 0.188 0.3 0.243 $ cpm : num 2.18 3.21 1.07 $ cpp : num 2.41 3.25 1.36 $ ctr : num 1.16 1.071 0.439 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 46 / 59
  • 54. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Expected results: $ adgroup_id : chr "..." "..." "..." $ campaign_id : chr "..." "..." "..." $ campaign_group_id : chr "..." "..." "..." $ account_id : chr "..." "..." "..." $ frequency : num 1.11 1.01 1.28 $ impressions : chr "431" "280" "2735" $ reach : int 390 277 2140 $ cpc : num 0.188 0.3 0.243 $ cpm : num 2.18 3.21 1.07 $ cpp : num 2.41 3.25 1.36 $ ctr : num 1.16 1.071 0.439 Response: Failed to connect to 2a03:2880:20:4f06:face:b00c:0:1: Network is unreachable Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 46 / 59
  • 55. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 47 / 59
  • 56. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Response: Curl (52): Empty reply from server Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 47 / 59
  • 57. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 48 / 59
  • 58. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Response header: { "Vary":["Accept-Encoding"], "Content-Type":["text/html"], "X-FB-Debug":["..."], "Date":["Thu, 24 Sep 2015 16:38:27 GMT"], "Connection":["keep-alive"], "Content-Length":["19"], "status":["503"], "statusMessage":["Service Unavailable"] } Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 48 / 59
  • 59. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 49 / 59
  • 60. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Header: {"Content-Type":["text/html; charset=utf-8"], ..., "status":["502"], "statusMessage":["Error parsing server response"]} Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 49 / 59
  • 61. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Header: {"Content-Type":["text/html; charset=utf-8"], ..., "status":["502"], "statusMessage":["Error parsing server response"]} Response: <!DOCTYPE html> <html lang="en" id="facebook"> <head> <title>Facebook | Error</title> </head> <body> <h1 id="sorry">Sorry, something went wrong.</h1> <p id="promise">We re working on it and we ll get it fixed as soon as we can.</p </body> </html> Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 49 / 59
  • 62. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 50 / 59
  • 63. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Header: {"Content-Type":["application/json; charset=UTF-8"], ..., "status":["200"], "statusMessage":["OK"]} Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 50 / 59
  • 64. What Could Possibly Go Wrong? Query sent to Facebook: mystats <- fb_insights(date_preset = today , level = ad ) Header: {"Content-Type":["application/json; charset=UTF-8"], ..., "status":["200"], "statusMessage":["OK"]} Response: { "id":["..."], "account_id":["..."], "time_ref":[...], "async_status":["Job Failed"], "async_percent_completion":[0] } Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 50 / 59
  • 65. What Could Possibly Go Wrong? Possible issues with the API calls: 1 Network error (network is unreachable) 2 Curl error (52) 3 HTTP error (503) 4 JSON syntax error (HMTL) 5 Facebook API error message Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 51 / 59
  • 66. Error handling Possible issues with the API calls using fbRads from R : 1 Network error (network is unreachable) 2 Curl error (52) 3 HTTP error (503) 4 JSON syntax error (HMTL) 5 Facebook API error message Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 52 / 59
  • 67. Error handling > mystats <- fb_insights(date_preset = today , level = ad ) ERROR [2015-11-01 08:27:44] Possible network error: Empty reply from server INFO [2015-11-01 08:28:14] Retrying query for the 1 st/nd/rd time ERROR [2015-11-01 08:28:14] Possible network error: Empty reply from server INFO [2015-11-01 08:28:44] Retrying query for the 2 st/nd/rd time DEBUG [2015-11-01 08:28:44] Sync request failed, starting async request. DEBUG [2015-11-01 08:28:45] *** Async Job Not Started (0%). Waiting 2 seconds... DEBUG [2015-11-01 08:28:47] *** Async Job Started (0%). Waiting 10 seconds... ERROR [2015-11-01 08:28:57] {"id":["***"],..., "async_status":["Job Failed"]} INFO [2015-11-01 08:28:57] Retrying query for the 1 st/nd/rd time DEBUG [2015-11-01 08:28:57] *** Async Job Not Started (0%). Waiting 2 seconds... DEBUG [2015-11-01 08:29:00] *** Async Job Started (0%). Waiting 10 seconds... DEBUG [2015-11-01 08:29:10] *** Async Job Running (17%). Waiting 7.5 seconds... DEBUG [2015-11-01 08:29:17] *** Async Job Running (35%). Waiting 5.6 seconds... DEBUG [2015-11-01 08:29:23] *** Async Job Running (53%). Waiting 4.2 seconds... DEBUG [2015-11-01 08:29:28] *** Async Job Running (71%). Waiting 3.2 seconds... DEBUG [2015-11-01 08:29:31] *** Async Job Running (71%). Waiting 15.8 seconds... Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 53 / 59
  • 68. Support for async/batch queries > mystats <- fb_insights(date_preset = today , level = ad ) DEBUG [2015-11-01 08:28:56] Sync request failed, starting async request. DEBUG [2015-11-01 08:28:57] *** Async Job Not Started (0%). Waiting 2 seconds... DEBUG [2015-11-01 08:29:00] *** Async Job Started (0%). Waiting 10 seconds... DEBUG [2015-11-01 08:29:10] *** Async Job Running (17%). Waiting 7.5 seconds... DEBUG [2015-11-01 08:29:17] *** Async Job Running (35%). Waiting 5.6 seconds... DEBUG [2015-11-01 08:29:23] *** Async Job Running (53%). Waiting 4.2 seconds... DEBUG [2015-11-01 08:29:28] *** Async Job Running (71%). Waiting 3.2 seconds... DEBUG [2015-11-01 08:29:31] *** Async Job Running (71%). Waiting 15.8 seconds... Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 54 / 59
  • 69. https://github.com/cardcorp/fbRads Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 55 / 59
  • 70. Keyword-based targeting ## Number of R users on Facebook > (fbr <- fbad_get_search(q = rstats , type = adinterest )[, c(1:3, 6)]) id name audience_size topic 1 6003212345926 R (programming language) 1602320 Lifestyle and culture Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 56 / 59
  • 71. Keyword-based targeting ## Number of R users on Facebook > (fbr <- fbad_get_search(q = rstats , type = adinterest )[, c(1:3, 6)]) id name audience_size topic 1 6003212345926 R (programming language) 1602320 Lifestyle and culture ## Number of programmers on Facebook > fbprog <- fbad_get_search(q = programming language , type = adinterest ) > head(fbprog[order(fbprog$audience_size, decreasing = TRUE), ], 10)[, 1:3] id name audience_size 1 6003030200185 Programming language 269482400 67 6003017204650 PHP 37701920 2 6003476678525 Boo (programming language) 31028180 68 6004131486306 C++ 26812460 69 6003215894612 Ajax (programming) 14547070 3 6003682002118 Python (programming language) 14286850 70 6003127967124 JavaScript 12124380 4 6002979703120 Ruby (programming language) 11146690 5 6003437022731 Java (programming language) 9547610 71 6003568029103 Object-oriented programming 9490910 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 56 / 59
  • 72. Targeting overlaps ## US-based R users on Facebook > fbad_reachestimate(targeting_spec = list( + geo_locations = list(countries = US ), + flexible_spec = list(list( + interests = data.frame( + id = fbr$id, + name = fbr$name)))))$users [1] 200000 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 57 / 59
  • 73. Targeting overlaps ## US-based R users on Facebook > fbad_reachestimate(targeting_spec = list( + geo_locations = list(countries = US ), + flexible_spec = list(list( + interests = data.frame( + id = fbr$id, + name = fbr$name)))))$users [1] 200000 > fbprog <- data.table(fbprog)[name %in% c( + R (programming language) , + Python (programming language) , + Java (programming language) )] ## US-based R, Python or Java users on Facebook > fbad_reachestimate(targeting_spec = list( + geo_locations = list(countries = US ), + flexible_spec = list(list( + interests = data.frame( + id = fbprog$id, + name = fbprog$name)))))$users [1] 1700000 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 57 / 59
  • 74. Targeting overlaps ## US-based R, but non-Python or Java users on Facebook > fbad_reachestimate(targeting_spec = list( + geo_locations = list(countries = US ), + flexible_spec = list(list( + interests = data.frame(id = fbr$id, name = fbr$name))), + exclusions = list(interests = data.frame( + id = fbprog$id[1:2], + name = fbprog$name[1:2]))))$users [1] 190000 ## US-based R, Python and Java users on Facebook > fbad_reachestimate(targeting_spec = list( + geo_locations = list(countries = US ), + flexible_spec = list( + list(interests = data.frame( + id = fbprog$id[1], + name = fbprog$id[1])), + list(interests = data.frame( + id = fbprog$id[2], + name = fbprog$id[2])), + list(interests = data.frame( + id = fbprog$id[3], + name = fbprog$id[3])))))$users [1] 5300 Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 58 / 59
  • 75. Targeting overlaps Gergely Daroczi (@daroczig) fbRads: Facebook ads from R github.com/cardcorp/fbRads 59 / 59