Expand my Community achievements bar.

Dynamic links

Avatar

Level 3

Hello there!

I have an email that has a Download now CTA that should point to a link that is split based on the Country. There are a total of 14 different links and instead of creating 14 different emails with 14 different links can this be optimized so that we can have one HTML email that has some scripting and it will automatically prepares the link based on the subscriber's country value from the database?

Thanks so much!

4 Replies

Avatar

Level 2

This can be done multiple ways, depending on how your data and links are set up.  Three ways off the top of my head are:

1. The easiest way is to just use personalization within the link:

<a href="http://somelink.com/<%= recipient.country %>/download.pdf">...</a>

2. You can also use if/else or switch statements in the HTML template if the links are drastically different.

<% if (recipient.country=='XX') { %>

  <a href="">Some Link</a>

<% } else if (recipient.country=='YY') { %>

<a href="">Some other link</a>

<% } else { %>

  <a href="">Default</a>

<% } %>

3. You can create and populate a lookup table that you can join to the recipient table on country code and populate it with all the links.  This is better than #2 to manage (IMO).

CountryURL
XXwww.somelink.com
YYwww.otherlink.com

Depending on how you set it up, you just reference it as personalization data in the template.  I left off the "https", as you will need to add it in the template so Adobe can add tracking:

<a href="https://<%=recipient.countryLinks.url %>">...</a>

Avatar

Level 3

However we have 2 Recipients table in our instance with different namespaces. When i try to access it using recipient.country i'm receiving [object WppObject] as its value. i did this just to know what the variable recipient.country is pulling as its value.

Please advise.

Avatar

Level 2

The code above is not a full solution and was only provided to illustrate HOW to do it.  The final solution will be entirely dependent on your data and how your schemas are set up. 

That being said, recipient.country is a link to an already linked table out of the box and may or may not have data in it.  You can access the fields in that table by calling them after (ie recipient.country.label, etc.).