Script 1683: pause low performing keywords
Purpose:
The script pauses keywords with 0 conversions and 60+ clicks in the last 60 days, ensuring they have been active for at least 60 days.
To Elaborate
The Python script is designed to manage keyword performance in advertising campaigns by identifying and pausing keywords that are underperforming. Specifically, it targets keywords that have received 60 or more clicks but have not resulted in any conversions over the past 60 days. Additionally, these keywords must have been active for at least 60 days to be considered for pausing. This process helps in optimizing the budget allocation by ensuring that funds are not wasted on ineffective keywords, thereby improving the overall efficiency of the advertising strategy.
Walking Through the Code
- Initialization and Setup
- The script begins by defining a dictionary
MATCH_TYPE
to map different match types such as ‘EXACT’, ‘PHRASE’, and ‘BROAD’. - It then sets up the primary data source
inputDf
from a dictionarydataSourceDict
and specifies the columns that will be used for processing.
- The script begins by defining a dictionary
- Data Validation and Processing
- The script checks if the necessary columns (
Account
,Campaign
,Group
) exist in the input DataFrameinputDf
. - If the columns are present, it creates an output DataFrame
outputDf
with the relevant columns and sets the status of each keyword to “PAUSED”. - The
Marin Action
column is updated to reflect the date on which the keyword was paused.
- The script checks if the necessary columns (
- Error Handling
- If the required columns are not found in the input DataFrame, the script raises a
ValueError
to alert the user of the missing data, ensuring that the process does not proceed with incomplete information.
- If the required columns are not found in the input DataFrame, the script raises a
Vitals
- Script ID : 1683
- Client ID / Customer ID: 1306912115 / 69058
- Action Type: Bulk Upload (Preview)
- Item Changed: Keyword
- Output Columns: Account, Campaign, Group, Keyword, Match Type, Status, Marin Action
- Linked Datasource: FTP/Email Feed
- Reference Datasource: None
- Owner: Chris Jetton (cjetton@marinsoftware.com)
- Created by Chris Jetton on 2025-02-04 21:33
- Last Updated by Chris Jetton on 2025-02-04 22:06
> 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
48
49
50
51
52
53
54
##
## name: pause_low_performing_keywords
## description:
## Pause keywords with 0 Prime Start/Conv and 60+ clicks in the last 60 days (must have been live for 60 days)
##
## author:
## created: 2025-02-04
##
MATCH_TYPE = {
'EXACT': 'exact',
'PHRASE': 'phrase',
'BROAD': 'broad',
}
today = datetime.datetime.now(CLIENT_TIMEZONE).date()
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_GROUP = 'Group'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_KEYWORD = 'keyword'
RPT_COL_MATCH_TYPE = 'Match Type'
# primary data source and columns
inputDf = dataSourceDict["1"]
# 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_STATUS = 'Status'
BULK_COL_MARIN_ACTION = 'Marin Action'
outputDf[BULK_COL_STATUS] = "<<YOUR VALUE>>"
# user code start here
print(tableize(inputDf.head()))
# Check if the necessary columns exist after the adjustment
if all(col in inputDf.columns for col in [RPT_COL_ACCOUNT, RPT_COL_CAMPAIGN, RPT_COL_GROUP]):
# Output DataFrame
outputDf = pd.DataFrame({
'Account': inputDf[RPT_COL_ACCOUNT],
'Campaign': inputDf[RPT_COL_CAMPAIGN],
'Group': inputDf[RPT_COL_GROUP],
'Keyword': inputDf[RPT_COL_KEYWORD],
'Match Type': inputDf[RPT_COL_MATCH_TYPE],
'Marin Action': f"Paused on {today}",
'Status': "PAUSED"
})
print(outputDf)
else:
raise ValueError("The expected columns are not found in the adjusted DataFrame.")
Post generated on 2025-03-11 01:25:51 GMT