Script 1633: Always Push Budgets

Purpose

The script processes campaign data to update daily budget allocations based on recommendations.

To Elaborate

The Python script is designed to manage and update daily budget allocations for marketing campaigns. It takes input from a primary data source containing various campaign metrics and recommendations. The script extracts relevant information, such as account details, campaign identifiers, and recommended daily budgets, to create an output DataFrame. This output is structured to reflect the updated budget allocations, ensuring that campaigns are funded according to the latest recommendations. The script is part of a broader process to optimize campaign performance by aligning budget allocations with strategic goals and performance metrics.

Walking Through the Code

  1. Data Initialization:
    • The script begins by defining the primary data source and relevant columns from the input data. These columns include campaign details, performance metrics, and budget recommendations.
  2. Output DataFrame Creation:
    • An output DataFrame is initialized to store the processed data. The script maps the input data’s account, campaign, and campaign ID columns to the output DataFrame.
    • The recommended daily budget from the input data is assigned to the corresponding column in the output DataFrame.
  3. Data Display:
    • The script uses the tableize function to print the first few rows of both the input and output DataFrames, providing a quick view of the data transformation process.
  4. User Changeable Parameters:
    • Users can modify the input data source and the specific columns used for mapping and budget recommendations to tailor the script to different datasets or business needs.

Vitals

  • Script ID : 1633
  • Client ID / Customer ID: 1306927943 / 60270393
  • Action Type: Bulk Upload
  • Item Changed: Campaign
  • Output Columns: Account, Campaign, Daily Budget, Campaign ID
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: dwaidhas@marinsoftware.com (dwaidhas@marinsoftware.com)
  • Created by dwaidhas@marinsoftware.com on 2025-01-17 16:55
  • Last Updated by dwaidhas@marinsoftware.com on 2025-01-17 16:57
> 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
##
## name: Always Push Budgets
## description:
##  
## 
## author: 
## created: 2025-01-17
## 

today = datetime.datetime.now(CLIENT_TIMEZONE).date()

# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_CAMPAIGN_TYPE = 'Campaign Type'
RPT_COL_CAMPAIGN_STATUS = 'Campaign Status'
RPT_COL_PUBLISHER = 'Publisher'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_STRATEGY = 'Strategy'
RPT_COL_STRATEGY_TARGET = 'Strategy Target'
RPT_COL_IMPR = 'Impr.'
RPT_COL_CLICKS = 'Clicks'
RPT_COL_PUB_COST = 'Pub. Cost $'
RPT_COL_CTR = 'CTR %'
RPT_COL_CONV = 'Conv.'
RPT_COL_COST_PER_CONV = 'Cost/Conv. $'
RPT_COL_IMPR_SHARE = 'Impr. share %'
RPT_COL_LOST_IMPR_SHARE_BUDGET = 'Lost Impr. Share (Budget) %'
RPT_COL_LOST_IMPR_SHARE_RANK = 'Lost Impr. Share (Rank) %'
RPT_COL_SHARED_BUDGET = 'Shared Budget'
RPT_COL_PUBLISHER_BID_PORTFOLIO_NAME = 'Publisher Bid Portfolio Name'
RPT_COL_PUBLISHER_BID_STRATEGY = 'Publisher Bid Strategy'
RPT_COL_PUBLISHER_TARGET_CPA = 'Publisher Target CPA'
RPT_COL_PUBLISHER_TARGET_ROAS = 'Publisher Target ROAS'
RPT_COL_UNCONSTRAINED_RECOMMENDED_CPA_PER_ROAS_TARGET = 'Unconstrained Recommended CPA/ROAS Target'
RPT_COL_RECOMMENDED_CPA_PER_ROAS_TARGET = 'Recommended CPA/ROAS Target'
RPT_COL_DAILY_BUDGET = 'Daily Budget'
RPT_COL_UNCONSTRAINED_RECOMMENDED_DAILY_BUDGET = 'Unconstrained Recommended Daily Budget'
RPT_COL_RECOMMENDED_DAILY_BUDGET = 'Recommended Daily Budget'
RPT_COL_RECOMMENDATION_CONSTRAINTS = 'Recommendation Constraints'
RPT_COL_CAMPAIGN_ID = 'Campaign ID'
RPT_COL_DAILY_BUDGET_RECOMMENDATION_DATE = 'Daily Budget Recommendation Date'
RPT_COL_CPA_PER_ROAS_TARGET_RECOMMENDATION_DATE = 'CPA/ROAS Target Recommendation Date'
RPT_COL_PUBLISHER_BID_STRATEGY_SYSTEM_STATUS = 'Publisher Bid Strategy System Status'
RPT_COL_AUTO_PAUSE_DATE = 'Auto Pause Date'
RPT_COL_AUTO_PAUSE_REC_CAMPAIGN_STATUS = 'Auto Pause Rec. Campaign Status'
RPT_COL_AUTO_PAUSE_STATUS = 'Auto Pause Status'
RPT_COL_CAMPAIGN_OVERRIDE = 'Campaign Override'

# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_DAILY_BUDGET = 'Daily Budget'
BULK_COL_CAMPAIGN_ID = 'Campaign ID'
outputDf[BULK_COL_DAILY_BUDGET] = "<<YOUR VALUE>>"
outputDf[BULK_COL_CAMPAIGN_ID] = "<<YOUR VALUE>>"

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

# Create the output DataFrame
outputDf = pd.DataFrame()
outputDf[BULK_COL_ACCOUNT] = inputDf['Account']
outputDf[BULK_COL_CAMPAIGN] = inputDf['Campaign']
outputDf[BULK_COL_CAMPAIGN_ID] = inputDf['Campaign ID']
outputDf[BULK_COL_DAILY_BUDGET] = inputDf[RPT_COL_RECOMMENDED_DAILY_BUDGET]

# Print the first few rows of the output DataFrame
print(outputDf.head())

print(tableize(inputDf.head()))

Post generated on 2025-02-21 10:25:25 GMT

comments powered by Disqus