2

I have this piece of AMPscript which shows different preheaders based on language. Except two, GB and JP, all of the others show the relevant preheader. The data extension has the right value and it works perfectly fine for the rest of the countries so I'm a bit lost

        %%[  

    var @CustomerID,@cc,@lang,@prefCountry,@code,@campaign,@preheader

    set @CustomerID = [SubscriberKey]
    set @lang = Lookup("Recipients","language","CustomerID",@CustomerID)
    set @prefCountry = Lookup("Recipients","preferredcountryid","CustomerID",@CustomerID)
    set @cc = Lookup("Recipients","language","CustomerID",@CustomerID)
    set @campaign = concat(emailname_,@cc)
    set @code = concat(@campaign,-1)
    set @preheader = Lookup("autoBanner_Segmentation","preHeader_default","email_code",@code)


    %%[ /*UK targeting start*/
    if ((@lang=='en' and (@prefcountry==1 or empty(@prefcountry))) or ((@lang=='us' or @lang=='au' or @lang=='nz') and @prefcountry==1)) then 

    set @cc = 'gb'
    ]%%

    %%[ /*AU targeting start*/
    elseif ((@lang=='au' and (@prefcountry==27 or empty(@prefcountry))) or ((@lang=='us' or @lang=='en' or @lang=='nz') and @prefcountry==27) or (@prefcountry==29)) then 

    set @cc = 'au'
    ]%%

    %%[ /*US targeting*/
    elseif ((@lang=='us' and (@prefcountry==18 or empty(@prefcountry))) or ((@lang=='au' or @lang=='en' or @lang=='nz') and @prefcountry==18)) then 

    set @cc = 'us'
    ]%%

    %%[ /*NZ targeting*/
    elseif ((@lang=='nz' and (@prefcountry==35 or empty(@prefcountry))) or ((@lang=='au' or @lang=='en' or @lang=='us') and @prefcountry==35) or (@prefcountry==38)) then 

    set @cc = 'nz'
    ]%%

    %%[ /*DE targeting*/
    elseif (@lang=='de') then 

    set @cc = 'de'
    ]%%

    %%[ /*DA/DK targeting*/
    elseif (@lang=='da') then 

    set @cc = 'da'
    ]%%

    %%[ /*ES targeting*/
    elseif (@lang=='es') then 

    set @cc = 'es'
    ]%%

    %%[ /*FR targeting*/
    elseif (@lang=='fr') then 

    set @cc = 'fr'
    ]%%

    %%[ /*IT targeting*/
    elseif (@lang=='it') then 

    set @cc = 'it'
    ]%%

    %%[ /*JP targeting*/
    elseif (@lang=='ja') then 

    set @cc = 'jp'
    ]%%

    %%[ /*NL targeting*/
    elseif (@lang=='nl') then 

    set @cc = 'nl'
    ]%%

    %%[ /*RU targeting*/
    elseif (@lang=='ru') then 

    set @cc = 'ru'
    ]%%

    %%[ /*SV targeting*/
    elseif (@lang=='sv') then 

    set @cc = 'sv'
    ]%%

    %%[ /*ZH targeting*/
    elseif (@lang=='zh') then 

    set @cc = 'zh'
    ]%%

    %%[ /*ROW*/
    else 

    set @cc = 'en'
    ]%%

    %%[endif]%%
2

I think the issue was that you were appending the @cc variable before your conditional if statements, meaning that the @code you used in your lookup may not exist in the DE, causing it to return empty.

Try rearranging it like this:

    %%[  

var @CustomerID,@cc,@lang,@prefCountry,@code,@campaign,@preheader

set @CustomerID = [SubscriberKey]
set @lang = Lookup("Recipients","language","CustomerID",@CustomerID)
set @prefCountry = Lookup("Recipients","preferredcountryid","CustomerID",@CustomerID)
set @cc = Lookup("Recipients","language","CustomerID",@CustomerID)

%%[ /*UK targeting start*/
if ((@lang=='en' and (@prefcountry==1 or empty(@prefcountry))) or ((@lang=='us' or @lang=='au' or @lang=='nz') and @prefcountry==1)) then 

set @cc = 'gb'
]%%

%%[ /*AU targeting start*/
elseif ((@lang=='au' and (@prefcountry==27 or empty(@prefcountry))) or ((@lang=='us' or @lang=='en' or @lang=='nz') and @prefcountry==27) or (@prefcountry==29)) then 

set @cc = 'au'
]%%

%%[ /*US targeting*/
elseif ((@lang=='us' and (@prefcountry==18 or empty(@prefcountry))) or ((@lang=='au' or @lang=='en' or @lang=='nz') and @prefcountry==18)) then 

set @cc = 'us'
]%%

%%[ /*NZ targeting*/
elseif ((@lang=='nz' and (@prefcountry==35 or empty(@prefcountry))) or ((@lang=='au' or @lang=='en' or @lang=='us') and @prefcountry==35) or (@prefcountry==38)) then 

set @cc = 'nz'

endif

set @campaign = concat(emailname_,@cc)
set @code = concat(@campaign,-1)
set @preheader = Lookup("autoBanner_Segmentation","preHeader_default","email_code",@code)
]%%
4
  • 1
    thanks a lot, it worked – Duicug Nov 12 '19 at 15:53
  • its still confusing for me why did it show fine for the rest of the languages? – Duicug Nov 12 '19 at 16:00
  • Likely because most of them already had the language of the cc you are looking to utilize. E.g. NZ had a language of nz (which is what you set as default in top | cc = lang) so it was able to match, where the GB one had a lang of en which would not match. – Gortonington Nov 12 '19 at 16:06
  • makes perfect sense now, thank again – Duicug Nov 12 '19 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.