Script 977: Go Puff Script Keyword Landing Page & Keyword Match Type combination Tag

Purpose

Automating Dimension Tagging with the landing page in the dimension “Landing Page Dim” and the keyword and match type combination in the dimension “Keyword MatchType Dim”.

To Elaborate

The Python script automates the process of dimension tagging by extracting relevant columns from the input DataFrame and assigning them to the corresponding columns in the output DataFrame. It specifically focuses on tagging the landing page in the “Landing Page Dim” dimension and the keyword and match type combination in the “Keyword MatchType Dim” dimension. The script then prints the tableized version of the output DataFrame.

Walking Through the Code

  1. The script starts by defining the column names used in the input and output DataFrames.
  2. The relevant columns (account, campaign, group, keyword, match type) are copied from the input DataFrame to the output DataFrame.
  3. The landing page values from the input DataFrame are assigned to the “Landing Page Dim” column in the output DataFrame.
  4. The keyword and match type values are combined using the format “keyword - match type” and assigned to the “Keyword MatchType Dim” column in the output DataFrame.
  5. The tableized version of the output DataFrame is printed.

Vitals

  • Script ID : 977
  • Client ID / Customer ID: 1306927677 / 60270331
  • Action Type: Bulk Upload (Preview)
  • Item Changed: Keyword
  • Output Columns: Account, Campaign, Group, Keyword, Match Type, Landing Page Dim, Keyword MatchType Dim
  • Linked Datasource: M1 Report
  • Reference Datasource: None
  • Owner: Grégory Pantaine (gpantaine@marinsoftware.com)
  • Created by Grégory Pantaine on 2024-04-15 20:03
  • Last Updated by Grégory Pantaine on 2024-04-15 20:05
> 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
# Automating Dimension Tagging with:
# the landing page in the dimension: "Landing Page Dim"
# the keyword and match type combination in the dimension: "Keyword MatchType Dim"
# script name: Go Puff - Script: Keyword Landing Page & Keyword Match Type combination Tag
# base report name: "Autotagging: Keywords: Landing Page & Keyword MatchType Dimensions"
# Taken from Michael H's Library dimension tag from campaign name and adjusted + sorted via chatGPT.
# setup 2024-04-15 by Greg Pantaine

# Define column names
RPT_COL_CAMPAIGN = 'Campaign'
RPT_COL_ACCOUNT = 'Account'
RPT_COL_GROUP = 'Group'
RPT_COL_KEYWORD = 'Keyword'
RPT_COL_MATCHTYPE = 'Match Type'
RPT_COL_LANDINGPAGE = 'Landing Page'
BULK_COL_ACCOUNT = 'Account'
BULK_COL_CAMPAIGN = 'Campaign'
BULK_COL_GROUP = 'Group'
BULK_COL_KEYWORD = 'Keyword'
BULK_COL_MATCHTYPE = 'Match Type'
BULK_COL_LPDIM = 'Landing Page Dim'
BULK_COL_KWMT = 'Keyword MatchType Dim'

# Copy relevant columns from inputDf to outputDf
outputDf = inputDf[[BULK_COL_ACCOUNT, BULK_COL_CAMPAIGN, BULK_COL_GROUP, BULK_COL_KEYWORD, BULK_COL_MATCHTYPE]].copy()

# Assign landing page to 'Landing Page Dim' column
outputDf[BULK_COL_LPDIM] = inputDf[RPT_COL_LANDINGPAGE]

# Combine keyword and match type and assign to 'Keyword MatchType Dim' column
outputDf[BULK_COL_KWMT] = inputDf[RPT_COL_KEYWORD] + ' - ' + inputDf[RPT_COL_MATCHTYPE]

# Print the tableized version of the output DataFrame
print(tableize(outputDf))

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

comments powered by Disqus