Script 239: bid boost

Purpose

The Python script adjusts search bids for advertising campaigns based on specific criteria and conditions.

To Elaborate

The script is designed to optimize search bids for advertising campaigns by evaluating various conditions related to campaign names, group names, and historical conversions. It applies specific rules to determine whether a bid should be increased and by how much, ensuring that the adjusted bid does not exceed a predefined cap. The script also decides whether a bid override is necessary and sets an expiration date for the override. The primary goal is to enhance the effectiveness of advertising campaigns by strategically adjusting bids based on historical performance and campaign characteristics.

Walking Through the Code

  1. Initialization and Setup:
    • The script begins by defining constants for column names and a temporary status column.
    • It initializes a DataFrame df with relevant columns from the input data.
  2. Bid Adjustment Logic:
    • The set_search_bid function is defined to adjust the search bid based on campaign and group names, historical conversions, and a bid cap.
    • It checks for specific keywords in campaign and group names to determine the bid multiplier and cap.
    • If conditions are met, the bid is increased by a multiplier, ensuring it does not exceed the cap.
  3. Bid Override and Expiration:
    • The set_bid_override function determines if a bid override is necessary by comparing the test and current search bid.
    • The set_override_until function sets the expiration date for the bid override.
  4. Data Processing:
    • The script applies the set_search_bid function to the DataFrame to update the search bids.
    • It filters out rows where the test campaign is not updated and adds columns for bid override status and expiration date.

Vitals

  • Script ID : 239
  • Client ID / Customer ID: 1306913420 / 60268008
  • Action Type: Bulk Upload
  • Item Changed: Keyword
  • Output Columns: Account, Campaign, Group, Keyword, Match Type, Search Bid, Test, Override Until, Bid Override
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: Chris Jetton (cjetton@marinsoftware.com)
  • Created by Chris Jetton on 2023-07-14 21:59
  • Last Updated by Chris Jetton 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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528

RPT_COL_ACCOUNT = 'Account'
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_GROUP = 'Group'
RPT_COL_KEYWORD = 'Keyword'
RPT_COL_MATCH_TYPE = 'Match Type'
RPT_COL_HISTORICAL_CONVERSIONS = 'Historical Conversions'
RPT_COL_TEST = 'Test'
BULK_COL_SEARCH_BID = 'Search Bid'
BULK_COL_BID_OVERRIDE = 'Bid Override'
BULK_COL_OVERRIDE_UNTIL = 'Override Until'

VAL_STATUS_PAUSED = 'Not Updated'

# create temp column to store new status and default to empty
TMP_STATUS = RPT_COL_TEST + '_'
inputDf[TMP_STATUS] = np.nan

#outputDf[Search Bid] = "<<YOUR VALUE>>"

# Define a function to determine if bid override is needed and set the override until date
def set_bid_override(row):
    if row['Test'] != row['Search Bid']:
        return 'On'
    else:
        return 'Off'

def set_override_until():
    today = datetime.datetime.now(CLIENT_TIMEZONE).date()
    tomorrow = today + datetime.timedelta(days=2)
    return tomorrow.strftime('%m/%d/%y')
    #today = date.today()
    #return '2023-10-02'

# Define a function to determine the search bid based on campaign name, group, historical conversions, current search bid, and bid cap
def set_search_bid(campaign, group, historical_conversions, search_bid):
    primary_search_strings = ["RLSA", "Competitor", "Brand", "CallCenter", "ContactCenter", "Dialers", "IVR", "DT"]
    bid_cap = 35

    # Check if the campaign contains any of the primary search strings
    campaign_search_strings = [string for string in primary_search_strings if string in campaign]

    # Check if the group contains any of the specified strings
    group_search_strings = ["enterprise", "forrester", "gartner", "quadrant", "cisco", "five9", "incontact", "amazon+connect", "talkdesk"]
    group_contains_strings = any(word in group for word in group_search_strings)

    if len(campaign_search_strings) > 0:
        # If the campaign contains any primary search strings,
        # increase the search bid for each search string
        for search_string in campaign_search_strings:
            if "RLSA" in campaign and "Brand" not in campaign and "Competitor" not in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
            # RLSA campaign without Brand and Competitor
                bid_cap = 70 
                bid_multiplier = 1.20
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid
            elif "RLSA" in campaign and "Brand" in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
            # RLSA campaign with Brand
                bid_cap = 45
                bid_multiplier = 1.20
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid
            elif "RLSA" in campaign and "Competitor" in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
                # RLSA campaign with Brand
                bid_cap = 75
                bid_multiplier = 1.20
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid

            elif "Brand" in campaign and "RLSA" not in campaign  and "NonBrand" not in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
                bid_multiplier = 1.20
                bid_cap = 40
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid

            #elif "Competitor" in campaign and "RLSA" not in campaign:
                #bid_multiplier = 1.25
                #bid_cap = 60
                #increased_bid = search_bid * bid_multiplier
                #if increased_bid <= bid_cap:
                    #search_bid = increased_bid

            elif "callcenter" in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
                bid_multiplier = 1.25
                bid_cap = 65
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid
                    
            elif "_DT" in campaign and "Quote" not in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
                bid_multiplier = 1.15
                bid_cap = 60
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid

            elif "contactcenter" in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
                bid_multiplier = 1.25
                bid_cap = 65
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid

            elif "Dialers" in campaign and "Quote" not in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
                bid_multiplier = 1.15
                bid_cap = 65
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid

            elif "IVR" in campaign and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
                bid_multiplier = 1.15
                bid_cap = 50
                increased_bid = search_bid * bid_multiplier
                if increased_bid <= bid_cap:
                    search_bid = increased_bid
            else:
                increased_bid = None  # Skip the row if no conditions are met

    elif group_contains_strings:
        # If the group contains any of the specified strings, set the bid cap and multiplier accordingly
        if any(word in group for word in ["cisco", "five9", "incontact", "amazon+connect", "talkdesk"]) and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
            bid_cap = 70
            bid_multiplier = 1.20
            increased_bid = search_bid * bid_multiplier
            if increased_bid <= bid_cap:
                search_bid = increased_bid
            else:
                increased_bid = None
                
        elif any(word in group for word in ["solution", "software", "system", "cloud", "ccaas"]) and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
            bid_cap = 70
            bid_multiplier = 1.15
            increased_bid = search_bid * bid_multiplier
            if increased_bid <= bid_cap:
                search_bid = increased_bid
            else:
                increased_bid = None

        elif any(word in group for word in ["8x8", "TalkDesk", "RingCentral"]) and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
            bid_cap = 70
            bid_multiplier = 1.05
            increased_bid = search_bid * bid_multiplier
            if increased_bid <= bid_cap:
                search_bid = increased_bid
            else:
                increased_bid = None

        elif any(word in group for word in ["Enterprise", "Forrester", "Partner", "Quadrant"]) and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
            bid_cap = 70
            bid_multiplier = 1.35
            increased_bid = search_bid * bid_multiplier
            if increased_bid <= bid_cap:
                search_bid = increased_bid
            else:
                increased_bid = None
                
        else:
            increased_bid = None  # Skip the row if no conditions are met

        # Check if the increased bid exceeds the bid cap, if not, update the search bid
        if increased_bid <= bid_cap:
            search_bid = increased_bid
        else:
            increased_bid = None

    # Check if historical conversions is greater than 0.0 and campaign is one of the pre-approved campaigns chosen by Genesys
    if historical_conversions > 0.0 and campaign in [
        "NA_NA_CallCenter_002_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Phrase",
	"NA_NA_Brand_003_DT_Phrase",
	"NA_NA_ContactCenter_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Exact",
	"NA_NA_Dialers_002_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Exact",
	"NA_NA_ContactCenter_002_DT_Exact",
	"NA_NA_Brand_003_DT_Exact",
	"NA_NA_RLSA_Brand_003_M_Exact",
	"NA_NA_RLSA_NonBrand_003_DT_Phrase",
	"NA_NA_IVR_002_DT_Exact",
	"NA_NA_Dialers_002_DT_Exact",
	"NA_NA_Competitors_001_DT_Phrase",
	"NA_NA_RLSA_Brand_003_DT_Phrase",
	"NA_NA_CallCenter_002_DT_Phrase",
	"NA_NA_RLSA_NonBrand_003_DT_Exact",
	"NA_NA_Competitors_001_DT_Exact",
	"NA_NA_IVR_002_DT_Phrase",
	"NA_NA_RLSA_Competitors_003_DT_Phrase",
	"NA_NA_Brand_003_DT",
	"NA_NA_RLSA_Brand_003_DT"
    ]:
        bid_multiplier = 1.25
        increased_bid = search_bid * bid_multiplier
        # Check if the increased bid exceeds the bid cap, if not, update the search bid
        if increased_bid <= bid_cap:
            search_bid = increased_bid
        else:
            increased_bid = None  # Skip the row if no conditions are met
        # Check if the updated bid exceeds the bid cap

    if increased_bid is not None:
        return round(search_bid, 2)

    else:
            return round(search_bid, 2)
       #  return round(search_bid, 2) if increased_bid is not None else round(search_bid, 2)


# set df to values of report columns
cols = [RPT_COL_ACCOUNT, RPT_COL_CAMPAIGN, RPT_COL_GROUP, RPT_COL_KEYWORD, RPT_COL_MATCH_TYPE, RPT_COL_HISTORICAL_CONVERSIONS, BULK_COL_SEARCH_BID, BULK_COL_BID_OVERRIDE, BULK_COL_OVERRIDE_UNTIL, RPT_COL_TEST]
df = inputDf[cols].copy()
outputDf['Test'] = inputDf['Search Bid']
# Apply the function to set the search bid column
outputDf['Search Bid'] = df.apply(lambda row: set_search_bid(row['Campaign'], row['Group'], row['Historical Conversions'], row['Search Bid']), axis=1)

# Remove rows where the test campaign is 'Not Updated'
outputDf = outputDf[outputDf['Test'] != outputDf['Search Bid']]

# Add the "Bid Override" column
outputDf['Bid Override'] = outputDf.apply(set_bid_override, axis=1)

# Add the "Override Until" column
outputDf['Override Until'] = set_override_until()

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

comments powered by Disqus