Script 13: Pause Campaigns with no active groups

Purpose

Pause campaigns with no active groups.

To Elaborate

The Python script aims to identify campaigns that have no active ad groups and pause them. This is useful for managing advertising campaigns on platforms like Amazon, where campaigns with no active ad groups are not effective and can be paused to optimize budget allocation.

Walking Through the Code

  1. The script defines column constants for the campaign, active groups, account, and Amazon bid adjustment product page.
  2. The output dataframe is initialized with a column for the campaign status.
  3. All values in the status column are set to NaN (not a number) using the numpy library.
  4. The script checks if the number of active groups for each campaign in the input dataframe is equal to 0.
  5. If a campaign has no active groups, the status column for that campaign is set to ‘Paused’.
  6. Rows with a non-empty status are selected and assigned to the output dataframe.
  7. The output dataframe contains only the campaigns that have been paused due to having no active ad groups.

Vitals

  • Script ID : 13
  • Client ID / Customer ID: 297978546 / 2
  • Action Type: Bulk Upload (Preview)
  • Item Changed: Campaign
  • Output Columns: Account, Campaign, Status
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: Michael Huang (mhuang@marinsoftware.com)
  • Created by Michael Huang on 2023-02-13 06:48
  • Last Updated by Michael Huang on 2024-03-13 04:02
> See it in Action

Python Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACTIVE_GROUPS = 'Active Groups'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_AMAZON_BIDADJPRODUCTPAGE = 'Amazon Bid Adj. Product Page'
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_STATUS = 'Status'

outputDf[BULK_COL_STATUS] = numpy.nan

# pause campaign if no active adgroups
outputDf.loc[ inputDf[RPT_COL_ACTIVE_GROUPS] == 0, BULK_COL_STATUS] = 'Paused'

# only include rows with non-empty Status

outputDf = outputDf[ outputDf[BULK_COL_STATUS].notnull() ]

Post generated on 2024-05-15 07:44:05 GMT

comments powered by Disqus