This topic describes special field functions in Velocity and ODR.
Use your specific data and recipient list fields, and test the field functions before using them in a mailing.
Different unsubscribe confirmation pages by recipient list
By default, the unsubscribe link in the mailing only redirects to one confirmation page. To display different unsubscribe confirmation pages depending on the recipient list (such as by language), you can use the following ODR code:
<odr:set value="%{user.data.userlist.id}" var="elid"></odr:set><odr:set value="(RECIPIENTLISTID_01|RECIPIENTLISTID_02)" var="de" ></odr:set><odr:set value="(RECIPIENTLISTID_03)" var="pl" ></odr:set><odr:choose> <odr:when test="%{matches(elid,de) or matches(elid,pl)}"> <odr:choose> <odr:when test="%{matches(elid,de)}"> <odr:out value="http://api.campaign.episerver.net/http/mail/{bmMailId}/unsubscribe?bmUrl=http://www.srv2.de/unsubscribe.html"></odr:out> </odr:when> <odr:when test="%{matches(elid,pl)}"> <odr:out value="http://api.campaign.episerver.net/http/mail/{bmMailId}/unsubscribe?bmUrl=http://www.srv2.de/unsubscribe_pl.html"></odr:out> </odr:when> </odr:choose> </odr:when> <odr:otherwise> <odr:out value="http://api.campaign.episerver.net/http/mail/{bmMailId}/unsubscribe?bmUrl=http://www.srv2.de/unsubscribe_en.html" ></odr:out> </odr:otherwise></odr:choose>
In this example, all recipients who are addressed via the recipient lists with the IDs RECIPIENTLISTID_01 or RECIPIENTLISTID_02 are forwarded to the German confirmation page after clicking the unsubscribe link. Recipients who are addressed via the recipient list with the ID RECIPIENTLISTID_03 are forwarded to the Polish confirmation page after clicking the unsubscribe link. Fallback is the English confirmation page.
Different unsubscribe confirmation pages by language
The following ODR code lets you redirect recipients whose language is stored in a recipient list field to the appropriate language version of the confirmation page after they click the unsubscribe link:
<odr:set value="%{lower(user.data.language)}" var="language"></odr:set><odr:set value="(german)" var="de" ></odr:set><odr:set value="(polish)" var="pl" ></odr:set><odr:choose> <odr:when test="%{matches(language,de) or matches(lang,pl)}"> <odr:choose> <odr:when test="%{matches(language,de)}"> <odr:out value="http://api.campaign.episerver.net/http/mail/{bmMailId}/unsubscribe?bmUrl=http://www.srv2.de/unsubscribe.html"></odr:out> </odr:when> <odr:when test="%{matches(language,pl)}"> <odr:out value="http://api.campaign.episerver.net/http/mail/{bmMailId}/unsubscribe?bmUrl=http://www.srv2.de/unsubscribe_pl.html"></odr:out> </odr:when> </odr:choose> </odr:when> <odr:otherwise> <odr:out value="http://api.campaign.episerver.net/http/mail/{bmMailId}/unsubscribe?bmUrl=http://www.srv2.de/unsubscribe_en.html" ></odr:out> </odr:otherwise></odr:choose>
Different online versions by language
The following Velocity codes let you display a text in the email header with a link to the online version of the mailing in different languages. Depending on which language is stored in the language recipient list field, the corresponding language version is displayed.
Online version with sending domain and mail ID
#set($lang = $!user.data.language.toLowerCase())#if ($lang.equals("de"))Wenn diese E-Mail nicht richtig angezeigt wird, klicken Sie <a href="https://www.example.com/ov?m2u={bmMailId}">hier</a>.<br />#elseIf this email does not display correctly <a href="https://www.example.com/ov?m2u={bmMailId}">click here</a> to view the online version.<br />#end
If you change the shipping domain, the online version can no longer be retrieved.
Online version via HTTP API
#set($lang = $!user.data.language.toLowerCase())#if ($lang.equals("de"))Wenn diese E-Mail nicht richtig angezeigt wird, klicken Sie <a href="https://api.campaign.episerver.net/http/mail/{bmMailId}/onlineversion?bmMailingId=$mailing.id">hier</a>.<br />#elseIf this email is not displayed correctly <a href="https://api.campaign.episerver.net/http/mail/{bmMailId}/onlineversion?bmMailingId=$mailing.id">click here</a> to view the online version.<br />#end
This Velocity code makes the online version independent of the sending domain.
Please sign in to leave a comment.