0

I'm populating a URL in a button in an email from a data field in my data extension. The URLs that come through from the database are a mix of some that have http at the beginning and some that do not. the ones that don't are not resolving after redirecting from the tracking URL. My only thought to the solution is check to see if the URL in the field has http the the beginning of it with ampscript and then add http:// if it's not there. Any more simple solutions? Thanks.

1 Answer 1

0

I'd tackle it the other way round.

Simply strip all http:// or https:// from all links with two Replace() functions (each does a "replace with nothing / empty string").

The base schema is:

Replace(@myUrlField,"https://","")

= "Replace in @myUrlField the string https:// with "" (empty string)."

Then you know for sure that all links are consistent, namely no prefix.

Then concat a leading http:// (sure it's not https://? I'll use https in my example.) with the result.

%%[
SET @myUrlField = Lookup(...)
SET @myConsistentLink = CONCAT("https://",REPLACE(Replace(@myUrlField,"https://",""),"http://",""))
]%%

This way all links are consistent AND conform to your schema.

You must log in to answer this question.

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