query_fb_marketing_api {rsocialwatcher} | R Documentation |
Query 'Facebook Marketing' API
Description
Query 'Facebook Marketing' API
Usage
query_fb_marketing_api(
location_unit_type,
lat_lon = NULL,
radius = NULL,
radius_unit = NULL,
location_keys = NULL,
location_types = c("home", "recent"),
locales = NULL,
interests = NULL,
behaviors = NULL,
college_years = NULL,
education_majors = NULL,
education_schools = NULL,
education_statuses = NULL,
family_statuses = NULL,
income = NULL,
industries = NULL,
life_events = NULL,
relationship_statuses = NULL,
work_positions = NULL,
work_employers = NULL,
excl_interests = NULL,
excl_behaviors = NULL,
excl_college_years = NULL,
excl_education_majors = NULL,
excl_education_schools = NULL,
excl_education_statuses = NULL,
excl_family_statuses = NULL,
excl_income = NULL,
excl_industries = NULL,
excl_life_events = NULL,
excl_relationship_statuses = NULL,
excl_work_positions = NULL,
excl_work_employers = NULL,
user_os = NULL,
wireless_carrier = NULL,
gender = c(1, 2),
age_min = 18,
age_max = 65,
flex_target = NULL,
version,
creation_act,
token,
sleep_time = 0.1,
show_result = FALSE,
verbose = TRUE,
add_query = FALSE,
add_query_hide_credentials = TRUE
)
Arguments
location_unit_type |
Either ——————————If location_unit_type is "coordinates" |
lat_lon |
Coordinates, c(lat, lon). For example, |
radius |
Radius around coordinate |
radius_unit |
Unit for radius; either ——————————If location_unit_type is not "coordinates" |
location_keys |
Key associated with location. Use the ——————————Other location parameters |
location_types |
Either: (1) |
locales |
Locales ID. For more information on locales, see the Advanced Targeting Documentation ——————————Parameters:
|
interests |
Interest IDs. For example, |
behaviors |
Behavior IDs. For example, |
college_years |
College graduation years. For example, |
education_majors |
Education major IDs. For example, |
education_schools |
School IDs. For example, |
education_statuses |
Education status IDs. For example, |
family_statuses |
Family status IDs. For example, |
income |
Income IDs. For example, |
industries |
Industries IDs. For example, |
life_events |
Life event IDs. For example, |
relationship_statuses |
Relationship status IDs. For example, |
work_positions |
Work position IDs. For example, |
work_employers |
Work employer IDs. For example, ——————————Exlcude Facebook users from query by select parameters |
excl_interests |
Interest IDs to exclude. |
excl_behaviors |
Behavior IDs to exclude. |
excl_college_years |
Colleage year IDs to exclude. |
excl_education_majors |
Education major IDs to exclude. |
excl_education_schools |
Education school IDs to exclude. |
excl_education_statuses |
Education status IDs to exclude. |
excl_family_statuses |
Family status IDs to exclude. |
excl_income |
Income IDs to exclude. |
excl_industries |
Industry IDs to exclude. |
excl_life_events |
Life event IDs to exclude. |
excl_relationship_statuses |
Relationship status IDs to exclude. |
excl_work_positions |
Work position IDs to exclude. |
excl_work_employers |
Work employer IDs to exclude. ——————————Non-Flexible parameters:
|
user_os |
User operating systems. For example, |
wireless_carrier |
Wireless carrier. If set to |
gender |
Genders to target; 1 targets males and 2 targets females. Default is both. See |
age_min |
Minimum age. Default is 18. See |
age_max |
Maximum age. Default is 65. See ——————————Flex targeting parameters |
flex_target |
Flexible targeting allows for more complicated parameter specifications. For example, specifying OR conditions across parameter types (eg, behaviors, interests, etc). For information on how to use flexible targeting, see the documentation here. ——————————Parameters for credentials |
version |
API version. e.g., "v19.0" |
creation_act |
Facebook creation act |
token |
Facebook API token ——————————Scraping parameters |
sleep_time |
How much time (in seconds) to pause between each query (default: |
show_result |
After each query, whether to print the number of monthly active users (default: |
verbose |
Display messages that indicate the function is pausing before making additional queries. Pausing can result from API key rate limits or no internet (default: ——————————Return query text |
add_query |
If |
add_query_hide_credentials |
If |
Value
Dataframe that includes (1) daily and monthly active users and (2) parameter values
See Also
get_fb_parameter_ids()
To get IDs and descriptions for behaviors, demographics, interests, and locales. For additional details on how to use the package, see the documentation here.
Examples
## Not run:
#### Define version, creation act, and token
VERSION = "enter-version"
CREATION_ACT = "creation_act"
TOKEN = "enter-token"
#### Query data
## All Facebook users in US
query_fb_marketing_api(
location_unit_type = "countries",
location_keys = "US",
version = VERSION,
creation_act = CREATION_ACT,
token = TOKEN)
## All Facebook users in US with interest in concernts
concert_id <- get_fb_parameter_ids(type = "interests", version = VERSION, token = TOKEN) %>%
filter(name == "Concerts (music event)") %>%
pull(id)
query_fb_marketing_api(
location_unit_type = "countries",
location_keys = "US",
interests = concert_id,
version = VERSION,
creation_act = CREATION_ACT,
token = TOKEN)
## End(Not run)