How to Personalise Server-Side Promotions – Part 2

Business Challenge

Our image assets for promotions have dollar values in them. We use an existing dynamic asset solution that can update text on an image. Can we use external image URLs in the promotion and replace a query string with a user profile object value?

Personalisation Solution

Step 1: Enter an external URL for each asset in the MCP promotion with ?txt=$value$. Assign one tag only with the content zone and dollar value for the image e.g. promoPageImage50. This is because content zones and tags cannot be duplicated within a promotion.

https://img1.niftyimages.com/pif/13lr/3o_r?txt=$value$

Step 2: Return an image URL for each content zone by checking which asset matches the content zone tag and the user’s profile object value.

const selectedBand:string = this.bandSelector.label;   
const userBandValue = context.user.profileObjects.GenerosityBands.GenerosityBands.attributes[selectedBand].value;

let fetchImageUrl = (promo: Promotion, contentZone: string): string => {
    if (!promo || !promo.assets) return "";

    for (const asset of promo.assets) {
        if (!isCdnOrExternalImage(asset)) continue;
        
        if (asset.contentZones?.includes(contentZone + userBandValue) {
            // Replace $value$ in external asset URL
            let banner = (asset as ImageAsset).imageUrl;
            if (banner.includes("$value$")) {
                banner = banner.replace("$value$",userBandValue);
            }                    
            return banner;
        }
    }
    return "";
}

let promoPageImageUrl: string = fetchImageUrl(promo, "promoPageImage");

https://img1.niftyimages.com/pif/13lr/3o_r?txt=50