1. Slack Request
  2. Gather data via API
  3. Compare the data between 2 date ranges.
  4. Send Report with TOP increasing & TOP dropping pages. (It can be clicks, Sign Ups, Leads…)

1. Setting up a Cloud Console project

  1. Create a Google Cloud Project.

  1. From your Google Workspace domain’s Admin console,go to Main menu menu > Security > API Controls.
  2. In the Domain wide delegation pane, select Manage Domain Wide Delegation.
  3. Click Add new.
  4. In the Client ID field, enter the service account’s Client ID. (You can find it under service accounts in GCP)
  5. In the OAuth scopes (comma-delimited) field, enter the list of scopes that your application should be granted access to. T
  6. You need to check the box that says “Overwrite existing client ID”
  7. Click Authorize.

2. Getting Search Console Data

3. Getting Google Analytics Data

ga_metrics=['ga:sessions', 'ga:newUsers', 'ga:avgTimeOnPage', 'ga:goal18Completions', 'ga:goal18ConversionRate']
google analytics API Python

  • df_last is the Data Frame with data from the most recent period (for example, last 30 days) and df_previous is the Data Frame with data from the previous period (previous 30 days). Both data frames follow the same structure.
  • kpi_metrics: This is a list of the metrics that we want to “compare”. In the case of search console we normally pass in [“clicks”,”impressions”], because those are the KPIs that we want to monitor.
  • join: This is a little dirty I know. But basically you need to specify which column should be use as join key . In the case of Search Console Data Frames the value of join will be “page” and when the Data Frames contain Google Analytics data the value of join will be “landingPagePath”
##Define some Global Variables
window=30 #we define a window
## Create the Auth Object
## Get the Reports
##Create Comparison

  • impressions_abs_diff
  • impressions_rel_diff
  • clicks_abs_diff
  • clicks_rel_diff
##Define Global Variables
ga_metrics=['ga:sessions', 'ga:newUsers', 'ga:avgTimeOnPage', 'ga:goal18Completions', 'ga:goal18ConversionRate']
ga_kpis=['newUsers', 'goal18Completions', 'goal18ConversionRate']
##Create Data Frames

['newUsers', 'goal18Completions', 'goal18ConversionRate']

4.1 Create the Slack Application

  1. Sign in to Slack and then navigate to Slack API
  2. Click on “Create an App” -> From Scratch

4.2. Creating the code and Sending it via Slack

  1. We have created a project in Google Cloud Console to connect to Search Console and Analytics APIs.
  2. We’ve got 2 different sets of Data Frames from Search Console and Google Analytics, and created a function to compare them.
  3. We now have a Data Frame that has a comparison of the data.

  1. Create a “comparison data frame” with data from Search Console OR Google Analytics.
  2. Extract the highlights of that Data Frame with .nlargest or .nsmallest
  3. Create a written report
  4. Send it via Slack
  • Nightwatch API / or other rank trackers: Moving forward, my plan is to connect to Nightwatch API, which is the rank tracking tool I’m using to monitor visibility. This way I should be able to combine visibility data with clicks, to get possible answers
  • Google Indexing API
  • HubSpot API.

Leave a Comment

Your email address will not be published. Required fields are marked *