This solution was created to automate the process of adding relevant Google Trends Rising and Top related queries into Google Ads Search Campaigns. It would help reduce some manual daily work and errors who is working or monitoring Search Campaigns and Google Trends keywords. Main code is written in Python 3.7.
Detail Setup Process written in Medium.com -- LINK
- This solution will NOT guarantee any Search Ads performance improvement
- pytrends API is not a Google Official API but it can be used for free
- Running the Python code daily basis will incur some Google Cloud cost
- It will not work if the query does not have any organic search volume to capture the search trend.
- Try to adjust the filter in case the search volume is low. ex) target from one country to Global
- Consider adding filter or alert in Google Ads side to avoid sudden ads spend increase
-
pytrends -- LINK
- API to get Google Trends data (not an official API by Google)
-
Google Cloud
-
Google Sheets API -- LINK
-
Google Ads Script -- LINK
Create New Spreadsheet (or copy this sample Spreadsheet) to store trending keywords you get from Google Trends. The Spreadsheet needs following four tabs.
- rising_brand
- rising_nonbrand
- top_brand
- top_nonbrand
The brand tab stores the queries which includes the keyword you are referencing and the non brand will store which doesn't include it.
exammple) You want to get Rising and Top related queries for "toyota"
In this case the brand keyword you reference is "toyota"
- rising_brand → "toyota camry 2020, ..."
- rising_nonbrand → "nissan sentra 2020, ..."
- top_brand → "toyota prius, ..."
- top_nonbrand → "hybrid car, ..."
Enable the Google Sheets API from below link in order to save data you get from pytreds.
https://developers.google.com/sheets/api/quickstart/python
Save the file credentials.json. This file needs to be uploaded later into Google Cloud Function.
Create Google Cloud Pub/Sub Topic so that Google Cloud Function can be triggered. This Topic will recieve message from Google Cloud Scheduler which we will set up in the following section.
- Create a new Google Cloud Scheduler job
- Set the frequency in unix-cron format. Weekly or Daily might be already enough.
- Select your timezone
- Target Pub/Sub
- Input the Cloud Pub/Sub Topic name you have created
- Set Payload with following parameters in JSON format
- "query" → the query you want to reference in Google Trends
- "language"
- "location"
- "time_frame" → date range you want to refenerence
- "ss_key" → Spreadsheet key you get from Spreadsheet URL.
- For more detail please follow the pytrends API parameters
exammple) Spreadsheet key for https://docs.google.com/spreadsheets/d/1JNCdYSTR_fenS6AB0_RJAZ50nmt96tTPG1WMVgOkBx4/edit#gid=0 is "1JNCdYSTR_fenS6AB0_RJAZ50nmt96tTPG1WMVgOkBx4" after d/ till /edit.
- Create a new Google Cloud Function
- Set the Trigger with Cloud Pub/Sub with the Topic you have created
- Select coding language Python 3.7
- For Source Code select the Zip Upload option and uploads the following three files zipped together.
Google Ads Script Sample Code
Search Campaigns and AdGroup has to be created in advance in Google Ads UI separately. The sample code will update each four Spreadsheet sheets keywords into separate AdGroup following the Spreadsheet structure mentioned in step 1.
- Create Campaign and AdGroup
- Ad Group for "rising_brand", "rising_nonbrand", "top_brand" and "top_nonbrand"
- Create Google Ads Script
- Schedule the Script daily or weekly basis depending on the function trigger frequency.