Script 1367: Tag top KW's Google Brand

Purpose

The script identifies and tags the top 10 keywords with the highest cost per conversion from a Google Ads report.

To Elaborate

The Python script processes a Google Ads report to identify the top-performing keywords based on their cost per conversion. It selects the top 10 keywords with the highest cost per conversion and tags them as “Top Performer.” This helps in quickly identifying which keywords are driving the most conversions at the highest cost, allowing for strategic adjustments in advertising campaigns. The script assumes that the input data is already sorted by cost per conversion in descending order, ensuring that the most expensive conversions are prioritized for tagging.

Walking Through the Code

  1. Data Preparation
    • The script begins by defining several constants that represent column names used in the report and bulk data processing. These constants help in maintaining consistency and readability throughout the code.
  2. Data Processing
    • The script copies the first 10 rows of the input DataFrame, inputDf, into a new DataFrame, outputDf. This selection is based on the assumption that the input data is pre-sorted by the cost per conversion in descending order.
    • It then adds a new column, Top Keywords, to the outputDf DataFrame and assigns the value “Top Performer” to each of the selected rows. This tagging highlights the top 10 keywords for further analysis or reporting.
  3. Output
    • Finally, the script prints the outputDf DataFrame, which contains the top 10 keywords tagged as “Top Performer,” allowing users to review the results.

Vitals

  • Script ID : 1367
  • Client ID / Customer ID: 1306923239 / 60269197
  • Action Type: Bulk Upload
  • Item Changed: Keyword
  • Output Columns: Account, Campaign, Group, Keyword, Match Type, Top Keywords
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: Autumn Archibald (aarchibald@marinsoftware.com)
  • Created by Autumn Archibald on 2024-09-04 21:55
  • Last Updated by Autumn Archibald on 2024-09-04 21:59
> See it in Action

Python Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
RPT_COL_KEYWORD = 'Keyword'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_GROUP = 'Group'
RPT_COL_MATCH_TYPE = 'Match Type'
RPT_COL_STATUS = 'Status'
RPT_COL_TOTAL_DONATIONS = 'Total Donations (Conversions)'
RPT_COL_COST_PER_CONV = 'Cost/Conv. $'
RPT_COL_TOP_KEYWORDS = 'Top Keywords'

BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_GROUP = 'Group'
BULK_COL_KEYWORD = 'Keyword'
BULK_COL_MATCH_TYPE = 'Match Type'
BULK_COL_TOP_KEYWORDS = 'Top Keywords'

# Assign current date to a parameter
today = datetime.datetime.now(CLIENT_TIMEZONE).date()

# Copy the first 10 rows of input dataframe to a new dataframe
# **incoming report is sorted by highest cost/conv to the lowest cost/conv**
outputDf = inputDf.head(10)
outputDf[BULK_COL_TOP_KEYWORDS] = "Top Performer"

print("outputDf", tableize(outputDf))

Post generated on 2024-11-27 06:58:46 GMT

comments powered by Disqus