Script 159: Increase Campaign tCPA

Purpose

The script adjusts the target cost-per-action (tCPA) for campaigns based on their current cost per conversion, increasing it if the cost is below a specified threshold.

To Elaborate

The Python script is designed to optimize advertising campaign budgets by adjusting the target cost-per-action (tCPA) based on the current cost per conversion. Specifically, it targets campaigns where the cost per conversion is less than 1500 units of currency. For these campaigns, the script calculates a percentage difference and increases the tCPA by this percentage. This adjustment aims to enhance the efficiency of the campaign by allowing for a higher bid, potentially increasing the campaign’s reach and effectiveness. The script also includes a mechanism to track when the tCPA was last updated, ensuring that changes are not made too frequently, which could lead to instability in campaign performance.

Walking Through the Code

  1. Initialization and Setup
    • The script begins by defining several constants related to campaign and account data, such as campaign names, account identifiers, and status indicators.
    • It then assigns the current date to a variable, which is used to track when changes are made.
  2. Data Preparation and Calculation
    • A copy of the input DataFrame is created to store the modified data.
    • A temporary column is calculated to determine the percentage difference between the current cost per conversion and the threshold of 1500. This percentage is used to adjust the tCPA.
  3. tCPA Adjustment
    • The script calculates a new tCPA by increasing the existing tCPA by the calculated percentage difference.
    • This new tCPA is then updated in the output DataFrame.
  4. Output
    • The modified DataFrame is printed in a tabular format, showing the updated tCPA values for each campaign.

Vitals

  • Script ID : 159
  • Client ID / Customer ID: 1306924501 / 60269325
  • Action Type: Bulk Upload (Preview)
  • Item Changed: Campaign
  • Output Columns: Account, Campaign, Publisher Target CPA, Last Updated - tCPA
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: Byron Porter (bporter@marinsoftware.com)
  • Created by Byron Porter on 2023-06-02 21:37
  • Last Updated by lneels@marinsoftware.com on 2023-12-06 04:01
> 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
#
# Increase Campaign tCPA
#
# Byron Porter
# 2023-06-03
#
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN_STATUS = 'Campaign Status'
RPT_COL_SET_COST_PER_CONV = 'Set Lead (Set30) Cost/Conv.'
RPT_COL_PUB_TCPA = 'Publisher Target CPA'
RPT_COL_LAST_UPDATEDTCPA = 'Last Updated - tCPA'
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_DAILY_BUDGET = 'Daily Budget'
BULK_COL_LAST_UPDATEDDAILYBUDGET = 'Last Updated - Daily Budget'


# Assign current date to a parameter
today = datetime.datetime.now() #.date()


outputDf = inputDf.copy()

# create temp column to store new values and default to empty
percentage_diff = 1 - (inputDf['Set Lead (Set30) Cost/Conv.'] / 1500)

newcpa = inputDf['Publisher Target CPA'] * (1 + percentage_diff)

outputDf['Publisher Target CPA'] = newcpa

print(tableize(outputDf))

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

comments powered by Disqus