Skip to main content
ACC - Email Code

Important code to include in your Adobe HTML email body

Updated over a week ago

These four HTML code snippets should be included at the top of the email in this order:


Code to generate unique send id for tracking pixel

<%
function create_UUID() {
var dt = new Date().getTime();
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = (dt + Math.random() * 16) % 16 | 0;
dt = Math.floor(dt / 16);
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
});
return uuid;
}
var sendId = create_UUID();
%>


Code for Jacquard-generated personalisation

You may need to adjust the phraseeFirstName variable to the relevant field if you have an alternative source of First Name. Please speak to your Customer Success team to ensure that your language model contains the correct merge tags.

<%

var phraseeFirstName = recipient.firstName.charAt(0).toUpperCase() + recipient.firstName.substring(1, this.length).toLowerCase();

if (phraseeFirstName == '') {

var phraseeFirstNameColon = '';
var phraseeFirstNameComma = '';
var phraseeFirstNameStop = '';
var phraseeFirstNameSpace = '';
var phraseeFirstNameCommaEnd = '';

} else {

var phraseeFirstNameColon = phraseeFirstName + ': ';
var phraseeFirstNameComma = ', ' + phraseeFirstName;
var phraseeFirstNameStop = phraseeFirstName + '. ';
var phraseeFirstNameSpace = phraseeFirstName + ' ';
var phraseeFirstNameCommaEnd = phraseeFirstName + ', ';

}

%>

Code to replace standard variables in subject lines

This code requires the subject line variables to include spaces after the tag; e.g.

<%= phraseeFirstNameComma %> or <%= targetData.Variable %>

<%

function looseJsonParse(obj){
return Function('"use strict";return (' + obj + ')')();
}

if ( targetData.language_variant_text === null || targetData.language_variant_text == '' || targetData.language_variant_text === undefined) {
language_variant_text = '';
} else {
language_variant_text = targetData.language_variant_text;
}

if ( targetData.language_variant_preheader === null || targetData.language_variant_preheader == '' || targetData.language_variant_preheader === undefined) {
language_variant_preheader = '';
} else {
language_variant_preheader = targetData.language_variant_preheader;
}

for (var step = 0; step < 2; step++) {

var startSLTag = language_variant_text.search("<%=");

if (startSLTag !== -1) {
var endSLTag = language_variant_text.search("%\>");
var tagSLToRep = language_variant_text.substring(startSLTag + 3, endSLTag);
tagSLToRep = tagSLToRep.trim();
language_variant_text = language_variant_text.split("<%= " + tagSLToRep + " %\>").join(looseJsonParse(tagSLToRep));
}

}

for (var step = 0; step < 2; step++) {

var startPHTag = language_variant_preheader.search("<%=");

if (startPHTag !== -1) {
var endPHTag = language_variant_preheader.search("%\>");
var tagPHToRep = language_variant_preheader.substring(startPHTag + 3, endPHTag);
tagPHToRep = tagPHToRep.trim();
language_variant_preheader = language_variant_preheader.split("<%= " + tagPHToRep + " %\>").join(looseJsonParse(tagPHToRep));
}

}

%>

For ease of use, this snippet covers both subject line and preheader content but the preheader sections can be removed if not part of your language model.

Open tracking pixel

This should be included at the end of your email, immediately after the closing </body> tag.

<IMG
src="https://mail-tracking.phrasee.co/live/open?project_id=<%= targetData.project_id %>&campaign_id=<%= targetData.campaign_id %>&variant_id=<%= targetData.language_variant_id %>&batch_id=<%= targetData.mab_batch_id %>&send_id=<%= sendId %>"
width=1 height=1>

It requires the Code to generate unique send id for tracking pixel to also be included otherwise the emails will fail to process.

​Please proof your emails after adding these code snippets to ensure no rendering issues or conflicts with your existing content occur.

Did this answer your question?