Open millett-a opened 4 years ago
Anything I replaced will be marked with {{brackets}}
I took a look at this, and I think the issue comes from the adwords data having multiple Link Groups, and some of those Link Groups have more than one Linked Accounts. In my example above, I have 4 groups, one group has 7 accounts, one has 2 and the remaining only have one account (for 11 accounts total). I think that's where the error "Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 4, 11" is getting its numbers When I use ga_adwords_list on a property that only has one Link Group, it works fine
I believe that in the end, the only function I changed was the parse_ga_adwords_list function to be the following:
parse_ga_adwords_list <- function(x){
aaa <- Reduce(bind_rows, x$items$adWordsAccounts) o <- x %>% management_api_parsing("analytics#entityAdWordsLinks")# %>% n.times <- as_vector(lapply(x$items$adWordsAccounts, nrow)) o <- o[rep(seq_len(nrow(o)), n.times),] %>% cbind(aaa) %>% select(-adWordsAccounts, -entity.webPropertyRef.kind, -entity.webPropertyRef.href, -kind)
if(is.null(o)){ return(data.frame()) }
o
}
This is great thanks, makes sense it's altering the parsing of that function.
Give it a go now with the GitHub dev version
It's working for all of my use cases. Thanks for adding this into the package!
We need to check if the adwords info is null sooner (otherwise it breaks seq_len(nrow(o)) parse_ga_adwords_list <- function(x){
aaa <- Reduce(bind_rows, x$items$adWordsAccounts) o <- x %>% management_api_parsing("analytics#entityAdWordsLinks")
if(is.null(o)){ return(data.frame()) }
n.times <- as_vector(lapply(x$items$adWordsAccounts, nrow)) o <- o[rep(seq_len(nrow(o)), n.times),] %>% cbind(aaa) %>% select(-adWordsAccounts, -entity.webPropertyRef.kind, -entity.webPropertyRef.href, -kind)
o
}
What goes wrong
Trying to pull in a list of all the GA adwords accounts connected to a property, and nothing gets returned
Steps to reproduce the problem
I just ran the code with my accountID and proprtyID passed into the function
Expected output
Some sort of table with info about the adwords accounts?
Actual output
Error message: Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 4, 11 Error: API Data failed to parse.
Wrote diagnostic object to 'gar_parse_error.rds', use googleAuthR::gar_debug_parsing('gar_parse_error.rds') to debug the data_parse_function.
Before you run your code, please run:
options(googleAuthR.verbose=2)
and copy-paste the console output here.Check it doesn't include any sensitive info like auth tokens or accountIds - you can usually just edit those out manually and replace with say
XXX
'API Data failed to parse' diagnostics
If you have an error starting with:
API Data failed to parse.
gar_parse_error.rds
to your working directory.Session Info
Please run
sessionInfo()
so we can check what versions of packages you have installed googleAnalyticsR_0.8.0