fbGetMarketingStat: Get statistic by ad accounts.

View source: R/fbGetMarketingStat.R

fbGetMarketingStatR Documentation

Get statistic by ad accounts.

Description

fbGetMarketingStat is main function of rfacebookstat package, intended for load statiscit data by your ad, adset, campaign or account

Usage

fbGetMarketingStat(
  accounts_id = getOption("rfacebookstat.accounts_id"), 
  sorting = NULL, level = "account", breakdowns = NULL, 
	action_breakdowns = NULL, 
	fields = "account_id,campaign_name,impressions,clicks,reach,spend",
  filtering = NULL, date_start = NULL,
  date_stop = NULL, date_preset = "last_30d",
  attribution_window = NULL,
	api_version = getOption("rfacebookstat.api_version"), 
	action_report_time = NULL, interval = "day", 
	use_account_attribution_setting = FALSE,
	console_type = "progressbar", request_speed = "normal",
	fetch_by = NULL,
  username = getOption("rfacebookstat.username"),
  token_path = fbTokenPath(),	
	access_token = getOption("rfacebookstat.access_token"))

Arguments

accounts_id

ID of your ad account.

sorting

Field to sort the result, and direction of sorting. You can specify sorting direction by appending "_ascending" or "_descending" to the sort field. For example, "reach_descending". This array supports no more than one element. By default, the sorting direction is ascending.

level

Represents the level of result. Avable ad, adset, campaign, account.

action_breakdowns

group results in the actions field. You can use the following breakdowns for action_breakdowns, for details go, or see details

breakdowns

Permutations marked with an asterisk (*) can be joined with action_type and action_target_id. Avable age, country, gender, frequency_value, hourly_stats_aggregated_by_advertiser_time_zone, hourly_stats_aggregated_by_audience_time_zone, impression_device, place_page_id, placement, device_platform, product_id, region. See details.

fields

List of fields which you want get in R. You can find list of available fields at Facebook API documentation by this link.

filtering

Vector of filtring or JSON string with array of filtring parameters, on example "ad.effective_status IN ARCHIVED" [{/'field/':/'ad.effective_status/',/'operator/':/'IN/',/'value/':[/'ARCHIVED/']}, see filtring block for more examples

date_start

Start reporting date.

date_stop

End reporting day

date_preset

Represents a relative time range. This field is ignored if time_range or time_ranges is specified. One of: today, yesterday, this_month, last_month, this_quarter, lifetime, last_3d, last_7d, last_14d, last_28d, last_30d, last_90d, last_week_mon_sun, last_week_sun_sat, last_quarter, last_year, this_week_mon_today, this_week_sun_today, this_year

attribution_window

The conversion attribution window provides timeframes that define when we attribute an event to an ad on Facebook. See Attribution Window sections.

request_speed

Speed beetwen API request, "normal", "fast" or "slow", depend of you API access level.

fetch_by

Character, split your requst by time interval, one of: day, week, month, quarter, year.

api_version

Current Facebook API version.

action_report_time

Determines the report time of action stats.

interval

Character value for split by time interval, one of "day", "week", "month", "quarter", "year". By default = "day"

use_account_attribution_setting

When this parameter is set to true, your ads results will be shown using the attribution settings defined for the ad account.

console_type

Character value for manage console output message, one of "progressbar", "message". By default = "progressbar". See more at Detail

username

your username on Facebook

token_path

path to dir with credentials

access_token

Your facebook API token

Details

Console_type parameters, if chose "progressbar" you can see load progress in percent, and if chose "message" you get message about loading process.

Value

Data frame with statistic.

Breakdowns

Allowed values for breakdowns.

  • ad_format_asset

  • age

  • body_asset

  • call_to_action_asset

  • country

  • description_asset

  • gender

  • image_asset

  • impression_device

  • link_url_asset

  • product_id

  • region

  • title_asset

  • video_asset

  • dma

  • frequency_value

  • hourly_stats_aggregated_by_advertiser_time_zone

  • hourly_stats_aggregated_by_audience_time_zone

  • place_page_id

  • publisher_platform

  • platform_position

  • device_platform

Action Breakdowns

Group results in the actions field. You can use the following breakdowns for action_breakdowns. Now you can use next action breakdowns:

action_device

The device on which the conversion event you're tracking occurred. For example, "Desktop" if someone converted on a desktop computer.

action_destination

The destination where people go after clicking on your ad. This could be your Facebook Page, an external URL for your conversion pixel or an app configured with the software development kit (SDK).

action_reaction

The number of reactions on your ads or boosted posts. The reactions button on an ad allows people to share different reactions on its content: Like, Love, Haha, Wow, Sad or Angry.

action_target_id

The id of destination where people go after clicking on your ad. This could be your Facebook Page, an external URL for your conversion pixel or an app configured with the software development kit (SDK).

action_type

The kind of actions taken on your ad, Page, app or event after your ad was served to someone, even if they didn't click on it. Action types include Page likes, app installs, conversions, event responses and more.

action_type,action_reaction

Together of action types and reactions brekdown.

Available Combinations Of Breakdowns

Grouping types marked with an asterisk (*) can be combined with action_type, action_target_id, and action_destination (action_target_id).

  • action_type *

  • action_target_id *

  • action_device *

  • action_device, impression_device *

  • action_device, publisher_platform *

  • action_device, publisher_platform, impression_device *

  • action_device, publisher_platform, platform_position *

  • action_device, publisher_platform, platform_position, impression_device *

  • action_reaction

  • action_type, action_reaction

  • age *

  • gender *

  • age, gender *

  • country *

  • region *

  • publisher_platform *

  • publisher_platform, impression_device *

  • publisher_platform, platform_position *

  • publisher_platform, platform_position, impression_device *

  • product_id *

Attribution Window

The conversion attribution window provides time intervals that determine the attribution period of an event for advertising on Facebook. For background information, see Facebook Ads Help Center, How Attribution Reporting Works. We measure the actions that occur when a conversion event occurs and look back in time 1-day, 7-days, and 28 days. To view actions attributed to different attribution windows, use attribution_window.

account_default

Use the account level attribution window setting

default

The FB default attribution window is 1 day views, 28 day clicks

inline

Inline attribution only (0 day views, 0 day clicks)

1d_view

1 day views, 0 day clicks

7d_view

7 day views, 0 day clicks

28d_view

28 day views, 0 day clicks

1d_click

0 day views, 1 day clicks

7d_click

0 day views, 7 day clicks

28d_click

0 day views, 28 day clicks

1d_view_1d_click

1 day views, 1 day clicks

7d_view_1d_click

7 day views, 1 day clicks

28d_view_1d_click

28 day views, 1 day clicks

1d_view_7d_click

1 day views, 7 day clicks

1d_view_28d_click

1 day views, 28 day clicks

28d_view_28d_click

28 day views, 28 day clicks

Also you can get more than one attribution window in one request, for example attribution_window = c('default', '1d_view', '28d_view', '28d_click')

Filtering

Filters on the report data. This parameter is an array of filter objects. You can set string vector or JSON string with field, operator and value.

field

Field for filtering.

operator

One of EQUAL, NOT_EQUAL, GREATER_THAN, GREATER_THAN_OR_EQUAL, LESS_THAN, LESS_THAN_OR_EQUAL, IN_RANGE, NOT_IN_RANGE, CONTAIN, NOT_CONTAIN, IN, NOT_IN, STARTS_WITH, ANY, ALL, AFTER, BEFORE, NONE.

value

Field value for filtering.

Simple filtring:

Example vector

filtering = "publisher_platform IN instagram"

Example JSON

filtering = "[{'field':'publisher_platform','operator':'IN','value':['instagram']}]"

Example of using two or more conditions: filtering = "[{'field':'clicks','operator':'LESS_THAN','value':500},{'field':'impressions','operator':'GREATER_THAN','value':20000}]" Filtring by two or more conditions:

Example vector

filtering = c("clicks LESS_THAN 500", "impressions GREATER_THAN 20000")

Example JSON

filtering = '[{"field":"clicks","operator":"LESS_THAN","value":"500"},{"field":"impressions","operator":"GREATER_THAN","value":"20000"}]'

Filtring with operators IN_RANGE, NOT_IN_RANGE, IN, NOT_IN

Example vector

filtering = 'publisher_platform IN instagram,facebook'

Example JSON

filtering = '[{"field":"publisher_platform","operator":"IN","value":["instagram","facebook"]}]'

Author(s)

Alexey Seleznev

See Also

All avable field, and discription of all parameters you can see oh this link. More information about breakdowns and action brekdowns on this link. More information about action field in this documentation.

Examples

## Not run: 
fbStat <- fbGetMarketingStat(accounts_id = "act_xxxxxxxxxxxxxxx",
                             level = "campaign",
                             fields = "account_name,campaign_name,impressions",
                             breakdowns = "device_platform",
                             date_start = "2016-08-01",
                             date_stop = "2016-08-10",
			     interval = "day",
                             access_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx")

## End(Not run)

rfacebookstat documentation built on Sept. 29, 2022, 5:13 p.m.