Two-minute read: Custom Code for advanced email personalisation in Dynamics365 Marketing
Personalisation is the essence of email marketing. Making your messages relevant to your audience increases engagement and conversion rates. In Dynamics 365 Marketing it’s easy to add ‘simple’ personalisation into an email – for example to personalise the subject line with the contact’s name.
But what about more complex personalisation – such as rotating which image or messaging is presented according to the contact’s occupation? You could – if you wanted to, create multiple versions of your email, each with the appropriate content for the audience. Or, you could use a Custom Code block.
Custom code blocks are an OOTB design element in Dynamics365 Marketing. Simply drop the Custom code tile onto the design canvas and you’ll add a Custom Code content block to the design canvas.
Now for the (only) tricky bit – you need someone with some knowledge of Java coding to write you a short script. The one we’re using here is to rotate an image based on the contact’s last name (but it could be any field on the contact record). This code took one of our Devs a few minutes to write and test.
In case you can't read that, here's the code (with the image URLs changed):
{{else if (ne contact.lastname 'Bastow')}}<img src="https://mktdplp102asda.azureedge.net/e426aa95-2d9d-e911-a85e-000d3a6a4164/rqPV72w-_NKA3Cd" style="width: 568px">
{{/if}}
Now, simply cut & paste this code into the Custom Code properties box.
Create the rest of your email, ‘Check For Errors’, and assuming all is OK, test send to confirm the variants are working – making sure that one of your Test Contacts meets the condition (in our case, Lastname = Bastow), and that one doesn’t.
Check your email account for the test sends, and voila – the appropriate image appears, automagically.
This is a pretty simple example to show the principle. For another example (and with thanks for the inspiration), check out this post by Vincent Groenheijde on the Dynamics 365 Marketing Community Blog (here) on personalising an event confirmation with the relevant sessions that a contact has signed-up for.
(This post originally appeared on the Barhead.com blog, at barhead.com/two-minute-reads-custom-code-in-dynamics-365-marketing/)

Like
Report
*This post is locked for comments