0

I have a DE with a field that contains website addresses in this format www.websiteaddress.com stored as datatype = Text

I set the variable in my email as below

set @website = AttributeValue("webAddress")

I have a button in the email with

href = "%%=RedirectTo(@website)=%%"

When i press the button from the email it is prefixing our SAP along with other utm parameters and showing a 404 server error. example below.

https://click.OurSAPhere/www.websiteaddress.com?utm_source=sfmc&utm_medium=email&utm_campaign=example&utm_term=example&utm_id=0000&sfmc_id=000000

How can i make this work if i want to send people to the actual website as it says in the DE e.g. www.websiteaddress.com

2 Answers 2

1

All the URLs need to start with 'http' in order to work properly. Hence you will need to check, if the value where your URL is stored indeed starts with 'http'. This can be done using the indexOf function. I use this in combination with IIF function, to concat 'https://' in front of the url, in case it doesn't exist. This way, we prevent prepending the url with 'https://' in case this already is part of the string.

You also need the RedirectTo function in your href tag. This function is required when using the HTML hyperlink tag in emails when the hypertext reference (href) attribute is either an attribute or a variable and the hyperlink is a tracked email link. If link tracking in an email is not enabled when the email is sent, the RedirectTo function is not required. This is why your solution with having a link without RedirectTo works in preview, but not when the email is being sent (as here the tracking is enabled).

My below example illustrates this, and shows few examples of how links are handled, and how you can implement this fix:

%%[
SET @URL = 'www.google.com'
SET @httpURL = 'https://www.google.com'
SET @fixedURL = IIF(indexOf(@URL, "https://") == 1,@URL,CONCAT('https://',@URL))
]%%

<!-- This fails -->
<a href="%%=RedirectTo(@URL)=%%">URL</a><br>

<!-- This works -->
<a href="%%=RedirectTo(@httpURL)=%%">httpURL</a><br>

<!-- This works -->
<a href="%%=RedirectTo(@fixedURL)=%%">fixedURL</a><br>
0
0

Thank you @Lukas. A combination of concat and redirectto worked for me. My solution is below.

SET @website = AttributeValue(“web address”)
SET @trimmedWebsite = Replace(@website, "www.", "") 
SET @websiteUrl = CONCAT("https://", @trimmedWebsite) 

href="%%=Redirectto(@websiteURL)=%%"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .