-
Notifications
You must be signed in to change notification settings - Fork 2
/
SAMPLECODE
34 lines (27 loc) · 1.36 KB
/
SAMPLECODE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
library(MicrosoftAdsR)
###For authorization and access token###
credentials <- list(
client_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
developer_token = "xxxxxxxxxxxxxxxx",
customer_id = "xxxxxxxx",
download_location = "C:\\R Data\\Digital Marketing\\Microsoft Ads\\%s",
filename = "bing_%s_%s_%s_%s_.zip", #reportid followed by startdate followed by enddate
startDate = format.Date(Sys.Date() - 7, "%Y-%m-%d"),
endDate = format.Date(Sys.Date() - 1, "%Y-%m-%d")
)
credentials <- Authentication(credentials)
#####Generate the data
#vector of account ids
accounts <- c( '123456789'
,'123784684'
,'211678457'
)
report <- "KeywordPerformanceReportRequest"
columns <- c("TimePeriod", "AccountNumber", "AccountId", "AccountName", "AccountStatus", "Network", "CampaignId", "CampaignStatus", "CampaignName", "AdGroupId","AdGroupName", "AdGroupStatus","KeywordId", "Keyword", "KeywordStatus", "BidMatchType", "DeliveredMatchType", "LandingPageExperience", "QualityImpact","AdRelevance", "AdDistribution", "QualityScore", "Impressions", "Clicks", "Spend", "AveragePosition", "Conversions")
dataList <- list()
for (account_id in accounts){
dataList[[account_id]] <-
(account_id=account_id)
report_id <- getReportId(credentials, report, columns, startDate, endDate)
downloadUrl <- getDownloadUrl(credentials, report_id)
}