SDITools / adobeanalyticsr

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

datarangeweek - missing data #163

Closed theCraver86 closed 11 months ago

theCraver86 commented 1 year ago

Hi Ben,

glad to be able to use your code to pull data from Adobe Analytics! Thanks!

I am not able retrive weekly data.

To better explain:

  1. I can extract data weekly based using dimension 'datareangeweek'
  2. In the table extracted the column 'week' is empty
  3. This behaviour is cross data range: day or week

I am available to answer any questions to investigate the case Many Thanks Riccardo

benrwoodard commented 1 year ago

Hey Riccardo! Glad you are finding the package useful. Make sure to use "daterangeweek" vs "datareangeweek" in your function argument 'dimensions' value. If you are and simply mistyped your question then please send a sample of your aw_freeform_table() request.

theCraver86 commented 1 year ago

Hi again,

thanks for the promp answer. It was a mistype the previous message, follow some more details:

E.g. Script

- Function

extract_df <- function(date, dimensions, metrics, top, search){
 data.frame(
    aw_freeform_table(
      company_id = Sys.getenv("AW_COMPANY_ID"),
      rsid = Sys.getenv("AW_REPORTSUITE_ID"),
      date_range = date,
      dimensions = dimensions,
      metrics = metrics,
      top = top,
      page = 0,
      filterType = "breakdown",
      segmentId = NA,
      metricSort = "desc",
      include_unspecified = FALSE,
      search = search,
      prettynames = TRUE,
      debug = FALSE,
      check_components = TRUE
    )
  ) 
}

- Login JWT

  aw_auth_with('jwt')
  aw_auth()

- Setup Default Variable

PW_start = '2023-09-18';

CW_start = as.Date(PW_start , "%Y-%m-%d") + 7;
CW_end = as.Date(PW_start , "%Y-%m-%d") + 13;
nDateRange = 2;
nCategory = 1;
nPrimaryCategory = 1;
nCountries = 20;

- E_xtract

dimensions <- c("**daterangeweek**","category","prop17", "evar9");
metrics <- c("revenue", "orders");
top = c(nDateRange, nCategory, nPrimaryCategory, nCountries);
search = c("", "MATCH 'FlightTicket'", "MATCH 'Booking'", "NOT '0' AND NOT 'APP'");

date <- c(CW_start, CW_end);
ff_top10Countries_purchase_CW <- extract_df(date, dimensions, metrics, top, search) %>% 
  mutate(Country = tolower(Country));

Follow the screenshot of the extraction with the first column empty: data week issue

Thanks And of course, feel free to ask questions that could help the understanding of the issue

benrwoodard commented 1 year ago

I just attempted to duplicate the issue on my end using your function. The result shows the 'Week' date value as expected. I don't have the the same dimensions you are showing so I can't really tell for sure where the issue is coming from. Have you tried diminishing the dimensions or the 'search' values to see if that helps at all?

benrwoodard commented 12 months ago

@theCraver86 were you able to figure out what the issue was? I was unable to reproduce the error on my end.

theCraver86 commented 11 months ago

Hi,

I run the code below edited from https://adobeanalyticsr.com/reference/aw_freeform_table.html:

extractMultipleWeek <- aw_freeform_table(
company_id = Sys.getenv("AW_COMPANY_ID"),
rsid = Sys.getenv("AW_REPORTSUITE_ID"),
date_range = c(Sys.Date() - 30, Sys.Date() - 1),
dimensions = c("daterangeweek"),
metrics = c("pageviews"),
top = c(5),
page = 0,
filterType = "breakdown",
segmentId = NA,
metricSort = "desc",
include_unspecified = TRUE,
search = NA,
prettynames = FALSE,
debug = FALSE,
check_components = TRUE
)

follow a table that shows what I edited:

Original Edit
dimensions = c("page", "lasttouchchannel", "mobiledevicetype") dimensions = c("daterangeweek")
metrics = c("visits", "visitors") metrics = c("pageviews")

Here what I get as output:

image

I really don't undestand what could be the thing, my two cent with my hypotheses:

  1. Something really silly . Maybe even not related with with code (eg 'confing of RStudio')
  2. The version of Adobe Analytics Edge (2.21.2)

Anyway I figured out a solution that works for me, we can stop further exploration on my part, but if I found some new hint I would update this thread.

Thanks for the time spent on this, appreciated.

If someone are facing same issue, follow the code that I wrote as workaround. It return 'visits' weekly with an added column (range) that contain correct label for week.

extract_df <- function(date, dimensions, metrics, top, search){

  data.frame(
    aw_freeform_table(
      company_id = Sys.getenv("AW_COMPANY_ID"),
      rsid = Sys.getenv("AW_REPORTSUITE_ID"),
      date_range = date,
      dimensions = dimensions,
      metrics = metrics,
      top = top,
      page = 0,
      filterType = "breakdown",
      segmentId = NA,
      metricSort = "desc",
      include_unspecified = FALSE,
      search = search,
      prettynames = TRUE,
      debug = FALSE,
      check_components = TRUE
    )
  )

}

extractMultipleWeek <- function(lastSunday, nWeek, dimensions, metrics, top, search){

  output = "";

  for (i in 1:nWeek){
    sWeek = as.Date(lastSunday , "%Y-%m-%d") - ((7*i)-1);
    eWeek = as.Date(lastSunday , "%Y-%m-%d") - (7*(i-1));

    date = c(sWeek, eWeek)

    df <- extract_df(date, dimensions, metrics, top, search) %>% 
      mutate(Range = sWeek)

    output = rbind(output,df)

  }
  output <- output %>% slice(-1)
  return(output)
}

lastSunday = '2023-10-01';
nWeek = 4;
dimensions <- c("daterangeweek");
metrics <- c("visits");
top = c(nWeek);
search = c("");

ff__visit <- extractMultipleWeek(lastSunday, nWeek, dimensions, metrics, top, search)