The goal of metatargetr
is to parse targeting information from the
Meta Ad Targeting
dataset
as well as retrieve data from the Audience
tab
in the Meta Ad Library.
You can install the development version of metatargetr like so:
remotes::install_github("favstats/metatargetr")
library(metatargetr)
The following code retrieves the targeting criteria used by the main page of the VVD (Dutch party) in the last 30 days. Just put in the right Page ID.
last30 <- get_targeting("121264564551002", timeframe = "LAST_30_DAYS")
head(last30, 5)
#> # A tibble: 5 × 16
#> value num_ads total…¹ type locat…² num_o…³ is_ex…⁴ custo…⁵ detai…⁶ ds
#> <chr> <int> <dbl> <chr> <chr> <int> <lgl> <chr> <chr> <chr>
#> 1 All 7 1 gend… <NA> NA NA <NA> <NA> 2023…
#> 2 Women 0 0 gend… <NA> NA NA <NA> <NA> 2023…
#> 3 Men 0 0 gend… <NA> NA NA <NA> <NA> 2023…
#> 4 Netherlan… 7 1 loca… countr… 0 FALSE <NA> <NA> 2023…
#> 5 13 0 0 age <NA> NA NA <NA> <NA> 2023…
#> # … with 6 more variables: main_currency <chr>, total_num_ads <int>,
#> # total_spend_formatted <chr>, is_30_day_available <lgl>,
#> # is_90_day_available <lgl>, internal_id <chr>, and abbreviated variable
#> # names ¹total_spend_pct, ²location_type, ³num_obfuscated, ⁴is_exclusion,
#> # ⁵custom_audience_type, ⁶detailed_type
The following code retrieves the targeting criteria used by the main page of the VVD (Dutch party) in the last 7 days. Just put in the right Page ID.
last7 <- get_targeting("121264564551002", timeframe = "LAST_7_DAYS")
head(last7, 5)
#> # A tibble: 5 × 16
#> value num_ads total…¹ type locat…² num_o…³ is_ex…⁴ custo…⁵ detai…⁶ ds
#> <chr> <int> <dbl> <chr> <chr> <int> <lgl> <chr> <chr> <chr>
#> 1 All 6 1 gend… <NA> NA NA <NA> <NA> 2023…
#> 2 Women 0 0 gend… <NA> NA NA <NA> <NA> 2023…
#> 3 Men 0 0 gend… <NA> NA NA <NA> <NA> 2023…
#> 4 Netherlan… 6 1 loca… countr… 0 FALSE <NA> <NA> 2023…
#> 5 13 0 0 age <NA> NA NA <NA> <NA> 2023…
#> # … with 6 more variables: main_currency <chr>, total_num_ads <int>,
#> # total_spend_formatted <chr>, is_30_day_available <lgl>,
#> # is_90_day_available <lgl>, internal_id <chr>, and abbreviated variable
#> # names ¹total_spend_pct, ²location_type, ³num_obfuscated, ⁴is_exclusion,
#> # ⁵custom_audience_type, ⁶detailed_type