0

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:

http://cl.s10.exct.net/%%[Output(v(@domain))]%%/customer/account/create/

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

1

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.

| improve this answer | |
  • 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? – Emil Stewart Mar 30 '18 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. – Stephan de Paly Mar 30 '18 at 20:42
1

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.

| improve this answer | |
  • 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. – Emil Stewart Apr 2 '18 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. – B.Bergey Apr 5 '18 at 6:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.