Hi,
In one of our accounts we use the current month of the year (as text; e.g : "July") in ad group names, headlines, descriptions, keywords, display URL, and URL (as numbers in URL; e.g : "2019-07").
The tedious things is we have to manually update all of that each first day of every month.
So what I'm looking for is a script to automate that.
*the months in text version have to be in French
*the timezone the script will be based on to check the date must be that of Paris (UTC+2 or CEST in summer and UTC+1 or CET in winter)
Here's the logic broken down in Python 3.7 below with some pseudo-code to replace the Adwords specific methods which I do not know :
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - -
from datetime import datetime
from dateutil.relativedelta import relativedelta
import locale
#Setting up the locale in French
locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
#Getting the current date and month in different formats
currentDate = datetime.now().day
current_month_text = datetime.now().strftime('%B').capitalize()
current_month_url = datetime.now().strftime('%Y'"-"'%m')
#Getting the previous date and month in different formats
lastDate = datetime.now() - relativedelta(months=1)
last_month_text = format(lastDate, '%B').capitalize()
last_month_url = format(lastDate,'%Y'"-"'%m')
#Dummy campaign ID variable to use
campaign = "id123456"
#Test variables to check if it works
essai = "les vacances de Juin"
essai_URL ="abc-2019-06"
#Conditional statement to change the old month for the current one in all desired fields when it is the first day of the month
if currentDate == 1:
#Below are two commented out tests I ran with the "essai" and "URL" variables to make sure it works as intended in Python.
#new_ads should give "les vacances de Juillet" (based on the variable "essai") while new_url should give "abc-2019-07" (based on the variable "essai_URL")
#new_ads = essai.replace(last_month_text,current_month_text)
#new_url = essai_URL.replace(last_month_url,current_month_url)
#Here's the pseudo-code for Adwords methods to get and update the different fields
new_headline2 = campaign.headline.replace(last_month_text,current_month_text)
new_GA_name = campaign.GA.replace(last_month_text,current_month_text)
new_KW = campaign.kw.replace(last_month_text,current_month_text)
new_description = campaign.description.replace(last_month_text,current_month_text)
new_display_url = campaign.display_url.replace(last_month_text,current_month_text)
#The URL is updated with the number format not text
new_url = campaign.url.replace(last_month_url,current_month_url)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - -
Could anyone help me translate that python code / pseudo-code into something workable in javascript / Adwords script methods?
Thank you in advance for your help