Analyze Seasonality Trend of Search Terms and Get a Complete Forecast

Analyze Seasonality Trend of Search Terms and Get a Complete Forecast

What is the seasonality trend of search terms?

The seasonality trend of search terms refers to the regular and predictable pattern of variation in the popularity or search volume of specific keywords or phrases over time. This pattern typically repeats itself within a certain period, such as weekly, monthly, or annually. The concept of seasonality is often associated with certain events, holidays, weather changes, or other factors that influence people’s behaviour and interests at specific times of the year.

Analyze Seasonality Trend of Search Terms and Get a Complete Forecast

We can get search trend data of a particular search term using Google Trends but if we want to get a trend data history of the past five years, then we couldn’t get that forecast from Google Trends.

Here we have come up with a solution! We have created a custom script of python to analyse the trend data of the past five years and get a forecast report.

Here are the steps to follow:

Step 1: Open Google Colab

Step 2: Insert code cell

Step 3: Type the code

Install pytrends library by copy pasting the following code and click the on the button:

!pip install pytrends –quiet

Install  peakutils library by copy pasting the following code and click the on the button:

!pip install peakutils –quiet

Import peakutils library:

import peakutils

from collections import Counter

Import other important libraries:

import pandas as pd

import numpy as np

import scipy.stats as sp

import matplotlib.pyplot as plt

Define Months of the year variables:

MONTHS = {1:’Jan’, 2:’Feb’, 3:’Mar’, 4:’Apr’, 5:’May’, 6:’Jun’, 7:’Jul’, 8:’Aug’, 9:’Sep’, 10:’Oct’, 11:’Nov’, 12:’Dec’}

Define get_peaks variable and the parameters:

def get_peaks(kw, geo=’UAE’, timeframe=’today 5-y’):


    A function to get the trend for a keyword and to spot when peaks happen.



    This func uses pytrends, an unofficial API for Google Trends

    .. _Pytrends Repo/Docs



    kw : str

        A search term.

    geo : str

        A two-letters string representing a country.

        Default: US

    timeframe : str

        A string representing the timeframe.

        Default: last 3 years.

        Nice timeframes to know:

        * Last 3 years: ‘today 3-y’

        * Everything: ‘all’


    from pytrends.request import TrendReq

    pytrend = TrendReq()

    pytrend.build_payload(kw_list=[kw], timeframe=timeframe, geo=geo)

    df =pytrend.interest_over_time()

    df.drop(columns=’isPartial’, inplace=True)

    df = df.resample(‘M’).mean()

    # line chart on resampled DF


    # bar chart on resampled DF,3))

    time_series = df[kw]

    cb = np.array(time_series)

    indices = peakutils.indexes(cb, thres=0.60, min_dist=0.1)

    months = []

    for i in indices:

        month = time_series.index[i].to_pydatetime().month

        val = int(time_series.iloc[i])


    print(“===PEAK MONTHS===”)



    #Uncomment the following lines if you want rising queries

    #print(“===RISING QUERIES===”)


    #Uncomment the following lines if you want top queries

    #print(“===TOP QUERIES===”)


Step 4: Insert the inputs to the program for getting the results

get_peaks(Hardwood flooring installation, US)

Here is the trend data forecast of past 5 years:

This data is for Hardwood flooring installation this search term, and US location.

This is how we can get the google search trend data forecast(5 years data) of the search terms and analyse the peak of the time when the search volume changes at most. 

A simple way to detect if and when a search term reaches a seasonal peak, using Google Trends data.

Practical use cases:

  • Decide the best month to update an existing article
  • Decide the best month to publish a new article

Here i am giving the colab experimented dashboard where you can just input your search terms to generate the trend data to analyse

Here is the link:


You may find some error while getting data of particular keywords, 

For example:
So don’t worry about that,  that will occur due unavailability of the data in google trend database. You need to input other form of search term and run the code.

Leave a Reply

Your email address will not be published.