Automating Personalization Block Batch Imports in Adobe Campaign v8
In Adobe Campaign v8, managing a large number of personalized content fragments efficiently is crucial for maintaining brand consistency across marketing campaigns. This article walks through an automated approach to import multiple HTML footers stored on an Adobe Campaign SFTP server and transform them into Personalization Blocks (PBs) for easy reference in email deliveries.
This project was needed for migrating from Responsys to Adobe Campaign.
Why Use Personalization Blocks?
Personalization Blocks in Adobe Campaign allow marketers to store reusable content snippets, such as headers, footers, and dynamic content, making it easy to maintain consistency across campaigns. In this case, we needed to import several hundred footers containing elements like company logos, unsubscribe links, help sections, and legal text.
Instead of manually creating each block, we leveraged an Adobe Campaign workflow with a JavaScript activity to automate the process.
Workflow Overview
The workflow consists of:
- JavaScript Activity: Reads HTML files from an SFTP folder, processes them, and creates corresponding Personalization Blocks.
- End Activity: Marks the workflow as complete.
This automation ensures that whenever new footers are uploaded to the designated SFTP folder, the workflow can be ran and the new files are programmatically converted into Personalization Blocks.
JavaScript Code Explanation
Function to Create a Personalization Block
// Function to create PB
function createPB(pbContents, label, internalName) {
var joinedContent = "";
for each(var line in pbContents) {
joinedContent += line;
}
var escapedContent = joinedContent.replace(/'/g, "\\'");
logInfo("Contents", escapedContent);
var newPB = <includeView xtkschema="nms:includeView" label="Test8" name="test8" contentType="1" _key="@name">
<source dependOnFormat="1" noEscaping="false">
<html></html>
</source>
<folder name="lnkLIFooters" _operation="none"/>
</includeView>;
var doc = new DOMDocument("html", "http://www.w3.org/1999/xhtml");
var cdata = doc.createCDATASection(escapedContent);
var fileName = pbContents.name;
var fileNameWithoutExtension = fileName.split(".")[0];
newPB.source.html = cdata.data;
newPB.@label = fileNameWithoutExtension;
newPB.@name = fileNameWithoutExtension;
logInfo("NEW PB", newPB.toXMLString());
xtk.session.Write(newPB);
pbContents.renameTo("/sftp/[insert-your-sftp]/incoming/import/personalization_blocks/history/");
}
Explanation:
- Reads the contents of an HTML file and processes it.
- Stores it as a CDATA section to preserve the formatting.
- Creates a new Personalization Block with a dynamic label and name.
- Saves the PB in the designated folder for easy retrieval.
- Moves the processed file to a history folder to prevent duplicate imports.
Reading and Processing Files from SFTP
var FOLDER_PATH = "/sftp/[insert-your-sftp]/incoming/import/personalization_blocks/";
var FILE_NAME_PATTERN = "*.htm*"; // Picks only .htm files
var objDirectory = new File(FOLDER_PATH);
var objFiles = objDirectory.list(FILE_NAME_PATTERN, true);
for each(var objFile in objFiles) {
logInfo("Processing File: " + objFile.name);
var PersonalizationBlockName = objFile.name.replace(".htm", "");
var htmlFile = new File(FOLDER_PATH + objFile.name);
htmlFile.open();
createPB(htmlFile, PersonalizationBlockName, PersonalizationBlockName);
htmlFile.close();
// htmlFile.remove(); // Uncomment to delete file after processing
}
Explanation:
- Connects to the specified SFTP folder.
- Lists all
.htm
files. - Iterates through each file, extracting its content.
- Calls the
createPB
function to generate a Personalization Block. - Closes the file (optional: removes it after processing).
Limitations of the Web UI
It is important to note that this method does not work correctly in the Web UI of Adobe Campaign v8. The script and automation rely on the Desktop Application to function as intended. Additionally, attempting to view the contents of imported Expression Fragments (which is what the Web UI calls Personalization Blocks) will display as empty in the Web UI.
Until Adobe updates the Web UI to reflect the Desktop Application’s functionality, it is my recommendation to avoid using the Web UI for managing Personalization Blocks.
Final Thoughts
This automation significantly reduces manual effort in maintaining email footers. Instead of creating and updating each footer individually, marketers can simply upload new HTML files to the SFTP folder, and the workflow will handle the rest.
If your team frequently updates branding elements or localized footers, this approach ensures a seamless and error-free process while keeping content centrally managed in Adobe Campaign.
Have questions or want to refine the script for your needs? Let’s discuss in the comments!