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

Description

Use case:

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.

Effectively, they requested to use the expression context in the brand configuration.eventDate - however, this populates the date in a very long/wordy format. They 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 for us and is often not updated on time.

Resolution

Resolution: We can 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