In this episode, I explain what Guide Template Language is in Salesforce Marketing Cloud and how to use it.
Hello and welcome back to mcChat. In this episode, I’ll explain what Guide Template Language is in Salesforce Marketing Cloud and why you might want to use it.
Guide Template Language, also referred to as ‘GTL’, is based on Mustache and Handelbars, which are both popular templating languages used in web development.
Let’s take a look at a simple use case for GTL.
In this example, I have a Sendable Data Extension containing customer data that I’ll use to personalise an email with recommended travel destinations. Note that I’ve included a field containing an array of JSON objects, with recommended destinations.
Now let’s take a look at my email. You can see I’ve included mustache tags in my email content. When used with a Sendable Data Extension, these tags effectively work in the same way as personalization strings, where the tag is substituted with a field value in my Data Extension.
In this email, I want to display formatted content with recommended destinations for each Subscriber.
To do this, I firstly use AMPscript to define the field name in my Data Extension that contains the JSON data.
I can then import that data by defining a data source in GTL and setting the data target as the AMPscript variable.
I now close off the data source tag where I want to stop personalising the repeating content.
Effectively, this works in a similar way to a process loop in AMPscript or SSJS, but I don’t need to define the how many times the loop should be executed, as GTL will just loop through the content within the data source tags for the total number objects in my JSON array.
And in my content, I’ve added tags which correspond to the keys in the JSON objects.
When I preview the email, the personalised content is repeated based on the number of items in the array.
This is just one of many use cases for GTL and there’s a lot more to the language than what I’ve showed you, as it includes built-in block helpers for conditionally rendering content, support for inline AMPscript within GTL tags, and more.
If you need to display JSON formatted data in Marketing Cloud, like sending a triggered order confirmation email or an abandoned cart email, then GTL is a great option for content personalisation.
Well, thanks for watching and please visit mc.chat for more tips in working with Salesforce Marketing Cloud. See you next time!