Script 293: Negative Keyword Expansion

Purpose

Python script for negative keyword expansion.

To Elaborate

This Python script is designed to expand negative keywords for a given dataset. Negative keywords are used in online advertising campaigns to prevent ads from being shown when certain keywords are present. The script takes an input dataset and adds additional columns for negative keywords based on specific business rules.

Walking Through the Code

  1. The script defines a dictionary called MATCH_TYPE that maps different match types to their corresponding values.
  2. The script initializes the variable today with the current date and time.
  3. The script assigns the value of the data source with the key “1” to the variable inputDf.
  4. The script defines constants for various column names used in the input dataset.
  5. The script defines constants for the output columns and initializes the BULK_COL_FRANCHISE column with a placeholder value.
  6. The script prints the table representation of the first few rows of the inputDf dataset using the tableize function.

Vitals

  • Script ID : 293
  • Client ID / Customer ID: 1306926711 / 60270099
  • Action Type: Bulk Upload (Preview)
  • Item Changed: Keyword
  • Output Columns: Account, Campaign, Group, Keyword, Match Type, Franchise
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: emerryfield@marinsoftware.com (emerryfield@marinsoftware.com)
  • Created by emerryfield@marinsoftware.com on 2023-09-12 04:03
  • Last Updated by Michael Huang on 2023-12-27 03:12
> 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
##
## name: Negative Keyword Expansion
## description:
##  
## 
## author: emerryfield@marinsoftware.com
## created: 2023-12-26
## 

MATCH_TYPE = {
  'EXACT': 'exact',
  'PHRASE': 'phrase',
  'BROAD': 'broad',
}
today = datetime.datetime.now(CLIENT_TIMEZONE).date()

# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_KEYWORD = 'Keyword'
RPT_COL_STATUS = 'Status'
RPT_COL_MATCH_TYPE = 'Match Type'
RPT_COL_PUBLISHER = 'Publisher'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_GROUP = 'Group'
RPT_COL_IMPR = 'Impr.'
RPT_COL_CLICKS = 'Clicks'
RPT_COL_PUB_COST = 'Pub. Cost $'
RPT_COL_CTR = 'CTR %'
RPT_COL_AVG_CPC = 'Avg. CPC $'
RPT_COL_IMPR_SHARE = 'Impr. share %'
RPT_COL_CONV = 'Conv.'
RPT_COL_COST_PER_CONV = 'Cost/Conv. $'
RPT_COL_CONV_RATE = 'Conv. Rate %'

# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_GROUP = 'Group'
BULK_COL_KEYWORD = 'Keyword'
BULK_COL_MATCH_TYPE = 'Match Type'
BULK_COL_FRANCHISE = 'Franchise'
outputDf[BULK_COL_FRANCHISE] = "<<YOUR VALUE>>"

# user code start here
print(tableize(inputDf.head()))

Post generated on 2024-03-10 06:34:12 GMT

comments powered by Disqus