Learn R Programming

rmytarget (version 2.4.0)

rmytarget-package: Paxkage for load data from 'MyTarget' API.

Description

Load data from API 'MyTarget' into R, by agancy clients and campaigns

Arguments

Details

The DESCRIPTION file: rmytarget rmytarget

References

1. MyTarget API documents 2. MyTarget API statistic methods 3. Authorization

Examples

Run this code
# NOT RUN {
# Get objects
## Get ads
Ads <- myTarGetAdList(login = "my_test_client")

## Get campaigns
Campaigns <- myTarGetCampaignList(login = "my_test_client")

# Get statistic
# base metrics by campaigns
base_data <- myTarGetTotalData(date_from   = Sys.Date() - 7,
                               date_to     = Sys.Date(),
                               object_type = "campaigns",
                               object_id = Campaigns$id,
                               metrics = "base",
                               stat_type = "day",
                               login = "my_test_client", 
                               token_path = "mytarget_token")

# all metrics by campaigns
all_data <- myTarGetTotalData(date_from   = Sys.Date() - 7,
                              date_to     = Sys.Date(),
                              object_type = "campaigns",
                              object_id = Campaigns$id,
                              metrics = "all",
                              stat_type = "day",
                              login = "my_test_client", 
                              token_path = "mytarget_token")

# custom set of metric by campaigns
custom_data <- myTarGetTotalData(date_from   = Sys.Date() - 7,
                                 date_to     = Sys.Date(),
                                 object_type = "campaigns",
                                 object_id = Campaigns$id,
                                 metrics = c("base", "tps", "viral"),
                                 stat_type = "day",
                                 login = "my_test_client", 
                                 token_path = "mytarget_token")


# if have note objects id, base metrics by ads
base_data2 <- myTarGetStats(date_from   = as.Date("2013-01-01"),
                                date_to     = Sys.Date(),
                                object_type = "banners",
                                metrics = "base",
                                stat_type = "day",
                                login = "my_test_client", 
                                token_path = "mytarget_token")
# }

Run the code above in your browser using DataLab