A Reference Block with link populated by Ampscript is throwing 404

ampscriptcontent-buildermarketing-cloud

Our emails are translated into 20 languages. The translations for each email are uploaded as a Data Extension with Country as primary key. Each email has its own DE.
One of the columns contains a CTA button link (www.link.com) and another with the text of the link.

While editing an email in Content Builder, I am getting the CTA button using Reference Content block. The blue button has the following code (extra styling removed):

<a href="%%=redirectto(@buttonBlueURL)=%%">%%=v(@buttonBlueText)=%%</a>

However, when we send a test email to ourselves and click the button, we get a 404. The content is populating as it should but the link looks like: "https://click.domain.com/www.link.com?utms=parameters"

The code snippet that is setting the @buttonBlueURL and @buttonBlueText variables is within the email itself (not in the Content Block), which I think may be the reason it's not working properly.

What is the best way to solve this? We want to use Reference Content blocks so that when we update design, we don't need to update every single email.

Best Answer

I suspect this issue is caused by the @buttonBlueURL variable not holding the complete URL.

Current situation:

%%[
SET @buttonBlueURL = 'www.link.com'
SET @buttonBlueText = 'Click me'
]%%
<a href="%%=redirectto(@buttonBlueURL)=%%">%%=v(@buttonBlueText)=%%</a>

Where the expected solution would be:

%%[
SET @buttonBlueURL = 'https://www.link.com'
SET @buttonBlueText = 'Click me'
]%%
<a href="%%=redirectto(@buttonBlueURL)=%%">%%=v(@buttonBlueText)=%%</a>
Related Topic