Google Trends data

Arkadiusz Wiśniowski
2025-09-17

Installing gtrendsR package

install.packages("gtrendsR")
# If not installed, the below packages may also need to be installed
install.packages("tidyr")
install.packages("dplyr")
install.packages("ggplot2")
install.packages("tibble")
install.packages("lubridate")

Loading packages needed for manipulation and plotting

Define search details

chosen keyword(s)

keyword = c("jobs in UK")

chosen geographic area

RO = Romania, PL = Poland, DE = Germany, FR = France, IT = Italy (large EU countries)

geo_area = c('RO','PL','DE','FR','IT')

chosen time period: 2012 - 2025

time_period = ("2012-01-01 2025-08-31")

preferred channel: web

channel='web'

Use gtrendsR to collect the data

trend_data = gtrends(keyword, gprop = channel, geo = geo_area, time = time_period)

Results

data over time

trend_over_time = trend_data$interest_over_time
head(trend_over_time)
        date hits    keyword geo                  time gprop category
1 2012-01-01   61 jobs in UK  RO 2012-01-01 2025-08-31   web        0
2 2012-02-01   46 jobs in UK  RO 2012-01-01 2025-08-31   web        0
3 2012-03-01   37 jobs in UK  RO 2012-01-01 2025-08-31   web        0
4 2012-04-01   44 jobs in UK  RO 2012-01-01 2025-08-31   web        0
5 2012-05-01   38 jobs in UK  RO 2012-01-01 2025-08-31   web        0
6 2012-06-01   38 jobs in UK  RO 2012-01-01 2025-08-31   web        0

plotting

plot <- ggplot(data = trend_over_time, aes(x = date, y = hits, group = keyword, col = keyword)) +
          geom_smooth(span = 0.2,se = FALSE) + xlab('Time') + ylab('Relative Interest') + 
          theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom",
            legend.text = element_text(size = 12)) + ggtitle("Google Search Volume")
plot

convert to quarterly data

trend_quarterly <- trend_over_time %>%
  mutate(quarter = ceiling_date(date, "quarter")) %>%   # create quarter variable
  group_by(geo, keyword, quarter) %>%                 # group by quarter
  summarise(hits = mean(hits), .groups = "drop") %>%      # average interest in a quarter
  mutate(quarter=quarter+months(2))                  # add two months to match the migration data 

Immigration from the EU to UK data

Source: ONS website, Data for Figure 3

immigration_df <- tribble(
  ~quarter,       ~Non_EU, ~EU,   ~British, ~Total,
  ymd("2012-06-01"), 238000, 327000,  74000,  639000,
  ymd("2012-09-01"), 232000, 322000,  76000,  630000,
  ymd("2012-12-01"), 230000, 334000,  79000,  643000,
  ymd("2013-03-01"), 224000, 350000,  75000,  649000,
  ymd("2013-06-01"), 222000, 373000,  75000,  669000,
  ymd("2013-09-01"), 233000, 410000,  78000,  720000,
  ymd("2013-12-01"), 234000, 402000,  76000,  713000,
  ymd("2014-03-01"), 236000, 414000,  80000,  731000,
  ymd("2014-06-01"), 236000, 420000,  82000,  737000,
  ymd("2014-09-01"), 239000, 441000,  81000,  761000,
  ymd("2014-12-01"), 241000, 457000,  81000,  778000,
  ymd("2015-03-01"), 240000, 457000,  83000,  780000,
  ymd("2015-06-01"), 241000, 454000,  83000,  778000,
  ymd("2015-09-01"), 240000, 453000,  81000,  774000,
  ymd("2015-12-01"), 238000, 481000,  78000,  797000,
  ymd("2016-03-01"), 235000, 490000,  78000,  803000,
  ymd("2016-06-01"), 237000, 521000,  74000,  832000,
  ymd("2016-09-01"), 238000, 496000,  70000,  804000,
  ymd("2016-12-01"), 237000, 465000,  70000,  772000,
  ymd("2017-03-01"), 239000, 447000,  72000,  759000,
  ymd("2017-06-01"), 241000, 399000,  78000,  718000,
  ymd("2017-09-01"), 251000, 425000,  78000,  754000,
  ymd("2017-12-01"), 257000, 411000,  84000,  752000,
  ymd("2018-03-01"), 261000, 399000,  76000,  736000,
  ymd("2018-06-01"), 269000, 407000,  81000,  757000,
  ymd("2018-09-01"), 284000, 397000,  85000,  766000,
  ymd("2018-12-01"), 330000, 421000,  74000,  825000,
  ymd("2019-03-01"), 346000, 429000,  74000,  849000,
  ymd("2019-06-01"), 347000, 413000,  61000,  821000,
  ymd("2019-09-01"), 351000, 376000,  66000,  793000,
  ymd("2019-12-01"), 368000, 349000,  71000,  788000,
  ymd("2020-03-01"), 388000, 347000,  80000,  815000,
  ymd("2020-06-01"), 331000, 333000,  72000,  736000,
  ymd("2020-09-01"), 260000, 293000,  53000,  606000,
  ymd("2020-12-01"), 294000, 316000,  52000,  662000,
  ymd("2021-03-01"), 297000, 287000,  44000,  629000,
  ymd("2021-06-01"), 368000, 279000,  62000,  709000,
  ymd("2021-09-01"), 534000, 249000,  96000,  878000,
  ymd("2021-12-01"), 611000, 172000, 108000,  891000,
  ymd("2022-03-01"), 721000, 138000, 110000,  968000,
  ymd("2022-06-01"), 848000, 121000, 108000, 1078000,
  ymd("2022-09-01"), 990000, 114000,  94000, 1198000,
  ymd("2022-12-01"),1053000, 116000,  88000, 1257000,
  ymd("2023-03-01"),1033000, 128000,  87000, 1248000,
  ymd("2023-06-01"),1025000, 129000,  84000, 1238000,
  ymd("2023-09-01"),1038000, 117000,  64000, 1219000,
  ymd("2023-12-01"),1031000, 126000,  61000, 1218000
)
trend_joint <- trend_quarterly %>%
  group_by(quarter) %>%
  summarise(hits=sum(hits)) %>%     # sum all interest across all five countries
  ungroup() %>%
  left_join(immigration_df) %>%     # join with ONS immigration data 
  mutate(hits=scale(hits),
         immi_EU=scale(EU)) %>%
  select(quarter,hits,immi_EU) %>%
  pivot_longer(cols = hits:immi_EU, names_to = c("series"), values_to = "value") 
plot <- ggplot(data = trend_joint, aes(x = quarter, y = value, group = series, col = series)) +
          geom_smooth(span = 0.1,se = FALSE) + xlab('Time') + ylab('Relative Interest') + 
          theme_bw() + theme(legend.title = element_blank(), legend.position = "bottom",
            legend.text = element_text(size = 12)) + ggtitle("Google Search Volume")
plot