I have an email in content builder that has multiple tags with href's that point to a dynamic domain.

See the screen shot below for an example. The HTML looks like this:

<a href="%%[Output(v(@domain))]%%/customer/account/create/">%%[Output(v(@domain))]%%/customer/account/create/</a>

The ampscript between the opening and closing tags works fine, but the ampscript in the href fails to execute.

In the email the href ends up with the ampscript being passed as plain text like this:


Any thoughts on why this is happening? Seems like a bug in the system.

Side Note : It works fine in the preview window in "Preview and Test" of content builder, but fails when the test email is actually sent.

ampscript fails on href

2 Answers 2


I'd do it like this:

var @URL
set @URL = concat(@domain,"/customer/account/create/")
<a href="%%=redirectto(@URL)=%%">%%=v(@URL)=%%</a>

The output() function is only for use inside an AMPscript block -- bound by the %%[ and ]%%. Outside of a block you can reference AMPscript functions with the double-percent notation -- %%= =%%.

The redirectto() function ensures clicks on the link are tracked.

  • 1
    Adam, you were right on, that did it, I can't say thank you enough. I'm going to buy a copy of that ampscript guide, seems like its much better than the stock documentation. I also attempted to do this but it didn't work: <a href="%%=redirectto(@domain)=%%/customer/account/create/">%%=v(@URL)=%%</a> It didn't work. Any idea why that doesn't work? Commented Mar 30, 2018 at 19:22
  • 2
    The redirectto function creates a link that points to the tracking server, so anything outside the variable won't be included. Unfortunately, concat doesn't work well nested in redirectto. You need to build your link variable as Adam did in his example. Commented Mar 30, 2018 at 20:42

Regarding... Side Note : It works fine in the preview window in "Preview and Test" of content builder, but fails when the test email is actually sent.

In the preview, tracking is not applied so the link works. When you do a test send or guided send, tracking is applied by default which breaks your link per comments above.

Always perform a tracked guided send prior to your prod send.

  • We are still in the process of porting things over from our other email marketing platform so still just learning the ropes with some test emails internally, but I'll keep that in mind for the future once we've fully gone live. Commented Apr 2, 2018 at 13:25
  • Good luck. Please also note that if you deploy a broken URL, it can be corrected in JobLinks tab after selecting your JobID under send tracking.
    – user55308
    Commented Apr 5, 2018 at 6:32

You must log in to answer this question.

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