Script 745: Golden Hippo Pause Ads Conversions
Purpose
Python script to pause ads if there are 0 conversions after $100 in spend.
To Elaborate
This Python script is designed to automate the process of pausing ads that have not generated any conversions after spending $100. It takes in a primary data source and identifies the ads that meet the specified criteria. The script then updates the status of these ads to “PAUSE” and outputs the modified data.
Walking Through the Code
- The script starts by importing the necessary libraries and defining the current date.
- It then defines the primary data source and the columns that will be used for analysis.
- Next, it sets up the output columns and their initial values.
- The user code begins by creating a temporary column to store the new status of the ads, which is initially set to “PAUSE”.
- The script selects the relevant columns from the input data and creates a copy of the dataframe.
- The temporary status column is renamed to the desired output column name.
- Finally, the modified dataframe is printed in a tabular format.
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-05-15 07:44:05 GMT