-
Notifications
You must be signed in to change notification settings - Fork 144
Description
I try to extract data from several accounts in one script.
few account has data and few empty, the problem is when no data i get an error message and the script stop to run.
Error message:
Your query matched 0 results. Please verify your query using the Query Feed Explorer and re-run it.
Error in GetDataFeed(query.uri) :
no loop for break/next, jumping to top level
How to fix it and skip the empty account without stop the script.
My script:
lastday <- Sys.Date() - 1
daystorun <- as.numeric(round(difftime(Sys.Date(), '2016-07-01'), digit=0))
for(i in 1:daystorun){
start.date <- as.character(lastday - daystorun + i)
end.date <- start.date
view.id <- paste("ga:",v,sep="")
query.list <- Init(start.date = start.date,
end.date = start.date,
dimensions = "ga:date, ga:medium, ga:source, ga:campaign",
metrics = "ga:users",
#max.results = 10000,
sort = "-ga:date",
filters = "ga:medium==XXXXX;ga:campaign=@xxxxxx;ga:source==XXXXXX",
table.id = view.id)
ga.query <- QueryBuilder(query.list)
ga.data <- GetReportData(ga.query, oauth_token, paginate_query = F)
ga.data["viewID"] <- paste(v)
df<-rbind(df,ga.data)
print(paste(start.date,"_",view.id))
}
}