How To Scrape Google Trends Data In R

Manpreet Singh
4 min readOct 19, 2020

Google Trends is an amazing tool which you can scrape data from, and you can do so fairly easily without using any API. We’ll be using R to do this, if you don’t have it installed checkout this article I did a few days ago on how to install R on your machine. Also, this is a VERY basic tutorial, if you want to do something somewhat more intensive i’ll make a separate tutorial whenever I feel like it :D

Assuming you have R & RStudio installed on your machine, let’s go ahead and get started! First thing first, the package we’ll be using is called “gtrendsR”, this is a package that we’ll use to pull the specific data points from Google Trends!

Start off by installing this package by typing this into the console at the bottom:

After this, we want to load the package into R, to do this, type this into the R Script:

Now, let’s go ahead and pull some data. But before that, gtrendsR has a pretty standard script to pull data, i’ll go ahead and explain it now but this is what the script looks like:

To begin, we start by typing “trends”, this just initializes R to use the gtrends package, after that where we put “ice cream” that would be the search term, so in this example we’re searching the term “ice cream” on google trends. The “no 1-H” indicates that we’re scraping data for the last hour, and the “geo =” portion indicates the location we are pulling the data from.

--

--

Manpreet Singh
Manpreet Singh

Responses (1)