vexersa / pytrends_googleads

Automate the process of adding Google Trends Keyword to Google Ads Search Campaigns

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Automate adding Google Trends Keyword to Google Ads Search Campaigns

Overview

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.

スクリーンショット 2020-06-13 16 55 20

スクリーンショット 2020-06-13 18 24 59

Detail Setup Process written in Medium.com -- LINK

Important Notes

  • 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

Products and APIs used for this solution

  • pytrends -- LINK

    • API to get Google Trends data (not an official API by Google)
  • Google Cloud

    • Google Cloud Function -- LINK

    • Google Cloud Pub/Sub -- LINK

    • Google Cloud Scheduler -- LINK

  • Google Sheets API -- LINK

  • Google Ads Script -- LINK

Setup Guide

1. Setup Google Spreadsheet and API Credencial

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.

Sample Credencial JSON file

2. Setup Google Cloud Pub/Sub

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.

スクリーンショット 2020-06-13 17 44 44

3. Setup Google Cloud Scheduler

  • 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.

スクリーンショット 2020-06-13 18 50 13

4. Setup Google Cloud Function

  • 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.

スクリーンショット 2020-06-13 19 14 26

5. Setup Google Ads Script

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.

スクリーンショット 2020-06-13 19 08 30

Thank you for reading :)

About

Automate the process of adding Google Trends Keyword to Google Ads Search Campaigns


Languages

Language:Python 59.1%Language:JavaScript 40.9%