Including “Event Date” in YYYY_MM format in Web Analytic Parameters

Description

Environment
Adobe Campaign Standard

Issue
Customers would like to include a web analytic parameter (utm_source) in links that go to their website, where the value is the date the email was sent, but in YYYY_MM format.

The purpose is to use the expression context in the brand configuration.eventDate.

However this populates the date in a very long/wordy format and need it to populate in YYYY_MM format.

Currently the utm_source parameter is hardcoded (e.g. ‘2020_10’).

The customer has to get the tech ops team to update each month via support tickets, which is very time-consuming and is often not updated on time.

Resolution

Solution
Use the below expression in utm_source to achieve the desired output:

context.eventDate.getFullYear().toString()+‘_’+(parseInt(context.eventDate.getMonth()+1).toString())

On this page