fbGetCostData: Get facebook ads cost data.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/fbGetCostData.R

Description

Get cost data for loading it into Google Analytics

Usage

1
2
3
4
5
6
7
8
9
fbGetCostData(
    accounts_id = getOption("rfacebookstat.accounts_id"),
    date_start         = Sys.Date() - 30,
    date_stop          = Sys.Date(),
    utm_source         = "facebook",
    utm_medium         = "cpc",
    username           = getOption("rfacebookstat.username"),
    token_path         = fbTokenPath(),
    access_token       = getOption("rfacebookstat.access_token"))

Arguments

accounts_id

ID of your ad account.

date_start

Start reporting date.

date_stop

End reporting day

utm_source

UTM source name for Google Analytics.

utm_medium

UTM medium name for Google Analytics.

username

your username on Facebook

token_path

path to dir with credentials

access_token

Your facebook API token

Details

Before loading data create data source at Google Analytics.

Value

Data frame with statistic.

Author(s)

Alexey Seleznev

See Also

Google Analytics: Understand Data Sets

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 

# Use googleAnalyticsR for upload data into Google Analytics
library(googleAnalyticsR)

# load cost data
cost_data <- fbGetCostData(accounts_id = "act_11111",
                           date_start  = "2020-05-10", 
                           date_stop   = "2020-05-14",
                           username    = "fb_login")
                              
# upload into GA source
ga_custom_upload_file(accountId          = xxxx, 
                      webPropertyId      = "UA-xxxx-1", 
                      customDataSourceId = 'abcdefg', 
                      cost_data)

## End(Not run)

rfacebookstat documentation built on April 17, 2021, 1:06 a.m.