Setup and Package Installation

Google Trends provides free product-level market data.

I also load the tidyverse for data manipulation, tidytext and textdata for text mining and sentiment lexicons, lubridate for date handling, and knitr/kableExtra for nicely formatted tables.

install.packages(c("remotes", "tidyverse", "tidytext", "textdata", "lubridate", "knitr", "kableExtra", "gtrendsR"))
library(tidyverse)
library(tidytext)
library(textdata)
library(lubridate)
library(knitr)
library(kableExtra)
library(ggplot2)
library(gtrendsR)

Data Collection & Scraping Methodology

I first used the gtrendsR package to query the Google Trends API for a 3-year window within the United States (geo = "US").

However, Google’s API appeared to be using aggressive rate-limiting, as I kept receiving a “Status code was not 200” error during complication, despite trying multiple workarounds.

Since it appeared NewsAPI would not provide the historical data needed for this assignment, I decided to obtain the data from Google Trends directly. I downloaded the data to APD_InterestOverTime.csv, and completed the processing and analysis steps locally in R.

Legacy Scraping Code (Archived due to API Rate-Limiting)

# This chunk is explicitly set to eval=FALSE to prevent compilation crashes, but documents the original scraping code that returned an error.
library(gtrendsR)
library(tidyverse)
library(lubridate)

safe_gtrends <- function(keyword, geo = "US", years = 3) {
  # Calculate dates
  start_date <- Sys.Date() - years(years)
  end_date   <- Sys.Date()
  
  # Format exactly as "YYYY-MM-DD YYYY-MM-DD"
  time_string <- paste(start_date, end_date, sep = " ")

  out <- tryCatch(
    {
      gtrends(keyword, geo = geo, time = time_string)
    },
    error = function(e) {
      # Changed to warning so you can actually see what the API error was
      warning("Google Trends request failed: ", e$message)
      return(NULL)
    }
  )

  out
}

# Run the function
trend <- safe_gtrends("Amazon Prime Day")

if (is.null(trend) || is.null(trend$interest_over_time)) {
  message("No data returned from Google Trends.")
  monthly <- tibble(
    month = as.Date(character()),
    interest = numeric()
  )
} else {
  monthly <- trend$interest_over_time %>%
    # Clean the 'hits' column before converting to numeric
    mutate(hits = if_else(hits == "<1", "0.5", hits)) %>% 
    mutate(
      hits = as.numeric(hits),
      month = floor_date(date, "month")
    ) %>%
    group_by(month) %>%
    summarize(interest = mean(hits, na.rm = TRUE), .groups = "drop")
}

glimpse(monthly)

Recommendation

I recommend the optimal window to launch a campaign is early to mid June, because this is when search interest in the main Amazon Prime Day event in mid-July begins intensifying, leading up to a spike in interest at the beginning of July of about 84. The benefit of this campaign timing is it capitalizes on the searches people are already doing at that time, which shows they are already interested and would likely be more receptive.

I noted there is a second smaller interest peak of about 34 in early October, which represented Amazon’s second discount event called “Prime Big Deal Days.” It makes sense that this would spike in my data, because it is likely customers also search for that event using the same “Amazon Prime Day” term. They may not understand the difference in the events, since both are heavily discounted sales.

It is important to note that in 2026, Amazon chose to move Prime Day from July to late June. This shows the importance of scanning real-world data as well, and not just historical data. As a result, the optimal campaign window this year would need to move up to May to capitalize on search interest.

References

Amazon moves Prime Day 2026 event to June. (Jun. 11, 2026). Digital Commerce 360. https://www.digitalcommerce360.com/article/everything-about-amazon-prime-day/

McLymore, Arriana. (Jun. 1, 2026) Amazon moves Prime Day to June, keeps it a four-day event. https://www.reuters.com/business/retail-consumer/amazon-moves-prime-day-back-june-keeps-it-four-day-event-2026-06-02/

The History of Amazon Prime Day. (Aug. 27, 2025). Amazon News. https://www.aboutamazon.com/news/retail/the-history-of-prime-day