I'm trying to use the Guide Template Language to provide a dynamic link in a triggered send, something like this:

<a href="{{My_Url}}">{{My Url}}</a>


<a href="{{My_Url}}">Your Account</a>

Also tried

<a href="{{My_Url [format=url-param-string]}}">{{My Url}}</a>

Suppose I pass { "My_Url": "http://www.example.com" }

What happens is that the tag in the HTML text is replaced with the provided value, but the href is ignored and therefore leads to a busted link.


  • Any particular reason you're using GTL instead of AMPScript? – Adam Spriggs Jan 28 '16 at 14:23
  • Hi Adam, honestly, I'm still learning the system. EDIT: we found out that GTL doesn't require linking to a data extension or a profile attribute the way that %%____%% substitution strings do, and we always provide template values from the API and do not want to persist them in ET (for now, for triggered emails). If we can achieve the same with AMP script, then I would love a link or a short example on how to do it. – gregsilin Jan 28 '16 at 17:08

GTL is limited in SFMC. I'd stick with AMPScript.

You can do what you're wanting with AMPScript in an email (triggered or otherwise):


var @firstName, @link
set @firstName = AttributeValue("firstName")
set @link = AttributeValue("link")


Hi%%=iif(not empty(@firstName),concat(", ",@firstName),"")=%%.
<br><br>Please, click this <a href="%%=redirectto(@link)=%%" alias="link">link</a>.

The firstName and link attributes don't have to have matching Profile Attributes or a columns in a Triggered Send templated Data Extension (it is a good practice, however). As long as you are passing them in the payload of your API call, you'll have access to them in the email.

There are a few more details in my answer on this question:

How do I pass data to an email via a triggered send?

  • Thank you Adam, this is exactly what we needed. And a conditional for free :) – gregsilin Jan 28 '16 at 22:05
  • 1
    On that note, what would you recommend GTL for? When GTL vs AMP? I'm guessing GTL is better for simpler examples when you just need to pass HTML without any logic or template processing. – gregsilin Jan 28 '16 at 22:06

It is possible to use the Guide Template Language to provide a dynamic link to an href attribute by placing the GTL tag inside of the AMPscript TreatAsContent() function. If you inline the AMPscript call into your href attribute it ends up looking like this:

<a href="%%=TreatAsContent('{{My_Url}}')=%%">Your Account</a>

Here is a sendable sample with the GTL setup:

%%[ var @Json set @Json ='{"My_Url":"http://www.example.com"}' ]%%


{{.dataobject JSONVar type=variable}}
        { "target" : "@Json" }

    <a href="%%=TreatAsContent('{{My_Url}}')=%%">Your Account</a>


NOTE: The extra step of using TreatAsContent is not necessary unless link tracking is enabled for the email.


We ended up using server side JavaScript simply because I was able to get it working with this approach.

We are passing in the following attribute data via the REST API.

{ "Test_Url": "http://www.google.com" }


<script runat=server>

  var testUrl = Platform.Recipient.GetAttributeValue("Test_Url");

  // Set AMPscript variable for URL
  Platform.Variable.SetValue("@testUrl", testUrl);



  <a href="%%=RedirectTo(@testUrl)=%%">Test Link</a>

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.