load_google_trends¶
load_google_trends(destination_table, keywords, start_month, geo, category, gprop)
Description¶
Load daily Google Trends
(search volume) of keywords
into destination_table
.
How it works
This function will:
- download daily search volume for each
keyword
for eachmonth
which are not already in destination table. Search volumes of the current month are downloaded anyway even if already in destination table. The daily search volumes are normalized between[0, 100]
for each(keyword, month)
. - download monthly search volume at once for all keywords altogether during the whole period. The downloaded volumes are then comparable for all keywords and the whole period.
- globally normalize the daily search volumes using the monthly search volumes to make them comparable.
(This function calls get_google_trends
function under the hood)
Destination Table Schema
Column | Description |
---|---|
date |
day of the trend |
keyword |
keyword |
search_volume |
search volume (normalized) |
_raw_search_volume |
search volume at load time (before global normalization) |
_raw_month_search_volume |
search month volume at load time (before global normalization) |
_load_date |
date when the data was downloaded from google trends |
Params
Param | Description |
---|---|
destination_table |
Fully qualified destination table (PROJECT.DATASET.TABLE) |
keywords |
Array of one to five search terms (a search term can be an expression) |
start_month |
First month (YYYY-MM ) to load data from |
geo |
Two letter country abbreviation. For example United States is 'US'. Defaults to World. More detail available for States/Provinces by specifying additional abbreviations. For example: Alabama would be 'US-AL'. For example: England would be 'GB-ENG' |
category |
Category to narrow results. Find available categories by inspecting the url when manually using Google Trends. The category starts after cat= and ends before the next & or view this wiki page containing all available categories. For example: "https://www.google.com/trends/explore#q=pizza&cat=71". '71' is the category. Defaults to no category |
gprop |
What Google property to filter to. Example 'images'. Defaults to web searches. Can be images, news, youtube or froogle (for Google Shopping results) |
You may need call this function several times a day
Google Trends put some quotas to request their API. For this reason, this function may not return data for all months in one call. But if you schedule this function to be called several times a day, you will certainly have all the data.
Examples¶
Call or Deploy load_google_trends
?
Call load_google_trends
directly
The easiest way to use bigfunctions
load_google_trends
function is deployed in 39 public datasets for all of the 39 BigQuery regions.- It can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- (You need to use the dataset in the same region as your datasets otherwise you may have a function not found error)
Public BigFunctions Datasets
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Deploy load_google_trends
in your project
Why deploy?
- You may prefer to deploy
load_google_trends
in your own project to build and manage your own catalog of functions. - This is particularly useful if you want to create private functions (for example calling your internal APIs).
- Get started by reading the framework page
Deployment
load_google_trends
function can be deployed with:
pip install bigfunctions
bigfun get load_google_trends
bigfun deploy load_google_trends
Download daily google trends comparing bigquery and snowflake
call bigfunctions.eu.load_google_trends('your_project.dataset.table', ['bigquery', 'snowflake'], '2024-01', null, null, null);
call bigfunctions.us.load_google_trends('your_project.dataset.table', ['bigquery', 'snowflake'], '2024-01', null, null, null);
call bigfunctions.europe_west1.load_google_trends('your_project.dataset.table', ['bigquery', 'snowflake'], '2024-01', null, null, null);
Need help or Found a bug using load_google_trends
?
Get help using load_google_trends
The community can help! Engage the conversation on Slack
We also provide professional suppport.
Report a bug about load_google_trends
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
We also provide professional suppport.
Spread the word!¶
BigFunctions is fully open-source. Help make it a success by spreading the word!