SDITools / adobeanalyticsr

R Client for Adobe Analytics API v2.0
Other
18 stars 9 forks source link

When using more than two dimensions getting error #179

Open szonekr opened 5 months ago

szonekr commented 5 months ago

So i am using the following to pull general day by day metrics for the analytics account i am trying to pull data from.

web_data_v1 <- aw_freeform_table(rsid = 'xxxxx', company_id = company_id, date_range = c("2023-07-08","2023-07-10"), top=(500000), dimensions = c("daterangeday","evar10"), metrics = c("pageviews","visits","visitors","bounces","averagetimespentonsite","bounces")).

This is works fine. However, when i try to add another dimension into this table set up evar2 which is a product identifier, i get the following error.

code web_data_v1 <- aw_freeform_table(rsid = 'xxxxx', company_id = company_id, date_range = c("2023-07-08","2023-07-10"), top=(500000), dimensions = c("daterangeday","evar10","evar2"), metrics = c("pageviews","visitors"))

error

Returning 8031 x 5 data frame Error in write - -------web_data_v1model <- aw_freeform_table(rsid = "xxxx", : could not find function "-<-"

any help here would be amazing, its not really making sense to me atm. Run time on the query also goes up to hours then decreases.

szonekr commented 4 months ago

also to add here, if i run, without putting this into a df =

aw_freeform_table(rsid = 'bmwuklimitedbmwgroup.retailers.prod', company_id = company_id, date_range = c("2023-07-08","2023-07-10"), top=(500000), dimensions = c("daterangeday","evar10","evar2"), metrics = c("pageviews","visitors")) %>% arrange(daterangeday)

it runs fine and i get an output into the console, but as soon as i try to assign this to a table i get errors

benrwoodard commented 4 months ago

This is quite strange. can you add debug = TRUE to your aw_freeform_table() function call and then screenshot the last part of the output in the console? I'm thinking the API calls are successfully pulling the data but there is something else going on with the '%>%' function or something else that is preventing it from collecting it into an object.

zugbug007 commented 4 months ago

Hi Szonkr, Long shot but just to check - are you referring to your R environment variables correctly in your code? I was able to replicate your error and then fix it by correcting the company and RSID to use the Sys.getenv() call. company_id = Sys.getenv("AW_COMPANY_ID") rsid = Sys.getenv("AW_REPORTSUITE_ID") Everything works fine with the additional evar2 dimension and pushing to tables.

szonekr commented 4 months ago

thanks for both getting back. For some reason now after running, the debug its running absolutely fine. Really appreciate the help. I will implement the sys.getenv as double down too thank you @zugbug007. Thanks again @benrwoodard

szonekr commented 4 months ago

have tried with the sys.getenv too and also didnt work for the larger data frame

szonekr commented 4 months ago

another error i see is:

Error in -.Date(left) : unary - is not defined for "Date" objects

charlie-gallagher commented 4 months ago

@szonekr sorry that you've been experiencing issues, however please do not include bearer tokens or other sensitive information in your issue comments -- these could be used to abuse your company's account.

The last error your posted here can be reproduced if you try:

-as.Date('2022-01-01')

I'm not sure why you're seeing that error though, that shouldn't happen in the code and I haven't seen it before.