Script 745: Golden Hippo Pause Ads Conversions
Purpose
The script pauses advertisements if they have zero conversions after spending $100.
To Elaborate
The Python script is designed to manage advertising campaigns by automatically pausing ads that have not generated any conversions after incurring a cost of $100. This is a cost-control measure to prevent further expenditure on underperforming ads. The script processes data from a primary data source, evaluates the performance of each ad, and updates their status to ‘PAUSE’ if they meet the specified criteria. This helps in optimizing the advertising budget by reallocating resources to more effective campaigns.
Walking Through the Code
- Data Preparation
- The script begins by defining the primary data source and relevant columns, which include account, campaign, group, creative ID, and status.
- A temporary column is created to store the new status of each ad, initialized to ‘PAUSE’.
- Data Processing
- The script selects specific columns from the input data frame, including account, campaign, group, creative ID, and the temporary status column.
- It then creates a copy of this subset and renames the temporary status column to match the output column format.
- Output Generation
- The processed data frame, which now contains the updated status for each ad, is printed in a tabular format for review.
Vitals
- Script ID : 745
- Client ID / Customer ID: 1306925431 / 60269477
- Action Type: Bulk Upload (Preview)
- Item Changed: Ad
- Output Columns: Account, Campaign, Group, Creative ID, Status
- Linked Datasource: M1 Report
- Reference Datasource: None
- Owner: Byron Porter (bporter@marinsoftware.com)
- Created by Byron Porter on 2024-03-06 20:07
- Last Updated by Byron Porter on 2024-03-06 20:11
> 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
##
## name: Golden Hippo - Pause Ads - Conversions
## description:
## Pauses ads if 0 conversions after $100 in spend
##
## author:
## created: 2024-03-06
##
today = datetime.datetime.now(CLIENT_TIMEZONE).date()
# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_GROUP = 'Group'
RPT_COL_CREATIVE_ID = 'Creative ID'
RPT_COL_STATUS = 'Status'
RPT_COL_TABOOLA_COST_PER_CONV = 'Taboola Cost/Conv $'
# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_GROUP = 'Group'
BULK_COL_CREATIVE_ID = 'Creative ID'
BULK_COL_STATUS = 'Status'
# user code start here
# create temp column to store new status and default to empty
TMP_STATUS = RPT_COL_STATUS + '_'
inputDf[TMP_STATUS] = 'PAUSE'
cols = [RPT_COL_ACCOUNT, RPT_COL_CAMPAIGN, RPT_COL_GROUP, RPT_COL_CREATIVE_ID, TMP_STATUS]
outputDf = inputDf.loc[ :, cols ].copy() \
.rename(columns = { \
TMP_STATUS: BULK_COL_STATUS \
})
print(tableize(outputDf))
Post generated on 2024-11-27 06:58:46 GMT