Script 1347: Assign Campaigns with Auto Pause Status = traffic

Purpose

The script assigns the ‘Auto Pause Status’ of ‘traffic’ to new campaigns that are part of a strategy but do not yet have this status applied.

To Elaborate

The Python script is designed to manage campaign statuses by identifying new campaigns that have been assigned to a strategy but have not yet been marked with the ‘Auto Pause Status’ of ‘traffic’. This is crucial for ensuring that all campaigns within a strategy are consistently monitored and managed according to predefined rules. The script processes data from a primary data source, extracts relevant campaign information, and updates the ‘Auto Pause Status’ field to ‘traffic’ for each campaign. This automated update helps maintain uniformity across campaigns, ensuring that they are all subject to the same traffic management protocols.

Walking Through the Code

  1. Data Initialization
    • The script begins by defining the primary data source and relevant columns, which include campaign details such as ‘Campaign’, ‘Campaign ID’, ‘Campaign Status’, ‘Publisher’, ‘Account’, ‘Strategy’, and ‘Auto Pause Status’.
    • An output DataFrame is initialized by copying specific columns from the input DataFrame, focusing on ‘Account’, ‘Campaign’, and ‘Campaign ID’.
  2. Status Assignment
    • The script assigns the value ‘traffic’ to the ‘Auto Pause Status’ column for all campaigns in the output DataFrame. This step ensures that all campaigns are marked with the appropriate status for traffic management.
  3. Verification
    • Finally, the script prints the first few rows of the modified DataFrame to verify that the ‘Auto Pause Status’ has been correctly updated to ‘traffic’ for each campaign.

Vitals

  • Script ID : 1347
  • Client ID / Customer ID: 1306927943 / 60270393
  • Action Type: Bulk Upload (Preview)
  • Item Changed: Campaign
  • Output Columns: Account, Campaign, Auto Pause Status, Campaign ID
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: dwaidhas@marinsoftware.com (dwaidhas@marinsoftware.com)
  • Created by dwaidhas@marinsoftware.com on 2024-08-27 19:42
  • Last Updated by dwaidhas@marinsoftware.com on 2024-08-27 19:42
> 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
##
## name: Assign Campaigns with Auto Pause Status = traffic
## description:
##  Picks up all new campaigns that are assigned to a strategy and do not have the Auto Pause Status = Traffic Dimensions applied to them yet.
## 
## author: Dana Waidhas 
## created: 2024-08-27
## 

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

# primary data source and columns
inputDf = dataSourceDict["1"]
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_CAMPAIGN_ID = 'Campaign ID'
RPT_COL_CAMPAIGN_STATUS = 'Campaign Status'
RPT_COL_PUBLISHER = 'Publisher'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_STRATEGY = 'Strategy'
RPT_COL_AUTO_PAUSE_STATUS = 'Auto Pause Status'

# output columns and initial values
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_AUTO_PAUSE_STATUS = 'Auto Pause Status'
BULK_COL_CAMPAIGN_ID = 'Campaign ID'

# Initialize output dataframe from input dataframe
outputDf = inputDf[[RPT_COL_ACCOUNT, RPT_COL_CAMPAIGN, RPT_COL_CAMPAIGN_ID]].copy()

# Assign 'traffic' to 'Auto Pause Status' for all campaigns
outputDf[BULK_COL_AUTO_PAUSE_STATUS] = 'traffic'

# Print the resulting dataframe to verify the changes
print(tableize(outputDf.head()))

Post generated on 2024-11-27 06:58:46 GMT

comments powered by Disqus