Building templates for a client in CONTENT BUILDER and we're using AMPscript at the top so a non-HTML user can insert the content they want to populate in the email.

Everything works great, until the customer wants to include a URL in the copy, as the SET statements get messy since the quotes in the a href close the SET statement.

We've tried using TreatAsContent, but did not have much luck as we couldn't get the URLs to get tracked. Here are a few things we tried.

SET @sub_trailer = "Lean more by clicking <a href="http://www.google.com">here</a>"

The above results in the URL missing and the code breaking, since the SET statement ends after the href="

We also tried

SET @link = "http://www.google.com"
SET @sub_trailer = "Learn more by clicking <a href="%%=RedirectTo(@link)=%%">here</a>

and that has the same issue as above.

We also tried the above and in the email itself using %%=TreatAsContent(@sub_trailer)=%% using the escape codes for the quotation marks SET @sub_trailer = "Learn more by clicking <a href=%22%%=RedirectTo(@link)=%%%22>here</a>, and while the content appears, the link doesn't track and it becomes "http://www.google.com" instead of just http:// and obviously it's not tracked.

We ended up simply pasting over the AMPscript displayed in the email (where %%=v(@sub_trailer)=%% appears)

  • This is a frustrating platform limitation -- only the first 100 unique URLs will get tracked per send job (as it relates to "external" content). Jun 22, 2018 at 17:01
  • Forgive my ignorance, but how does the 100 URL limit apply in this situation? Is the link not being treated like any other link? All other links are tracked and work ... it's only when we nest the AMPscript that the URL is not being tracked. Jun 25, 2018 at 13:49

1 Answer 1


There are a couple solutions to this:

  1. Using single quote (but keep in mind, this limits the content as well, e.g. Ronald's car would cause the same issue as your current double quote issue.

    SET @sub_trailer = 'Learn more by clicking <a href="%%=RedirectTo(@link)=%%">here</a>'

  2. Utilizing CONCAT()

    This will let you separate ampscript variables, and different sections of content from the overlying container.

    SET @link = "http://www.example.com" SET @sub_trailer = CONCAT('Learn more by clicking <a href="', RedirectTo(@link), '">here</a>')

  3. Storing in a data extension. If you are able to store the content inside of a data extension, then do a lookup or something to collect it into an AMPScript variable. Your content team would just need to do their editing inside of the DE instead of directly in the email.

So the best way I have found to do this is not really best practice at all, but it works.

You would wrap the whole thing in a TreatAsContentArea() function. You would have the 'name' of the content area be a variable that is unique to each email, to get around the weird 100 limitation that they have on it. Sample below:

SET @sub_trailer = TREATASCONTENTAREA(Concat(emailaddr, "_sub_trailer"), 'Learn more by clicking <a href="%%=RedirectTo(@link)=%%">here</a>')

You then have to call it inside the HTML using the TreatAsContent() function (no idea why...).


As I said, this is not best practice and can have repurcussions on execution run time, but it is really the ONLY way I have found that can get around this issue.

  • solution 1 works in that it will load the content and provide the URL, but the URL is not tracked, which is odd because the specific AMPscript in there is a "RedirectTo" <br /><br /> We have SET [at sign]link = "http://www.google.com" SET [at sign]track = RedirectTo([at sign]link) <br /><br /> followed by <br /> <br /> SET [at sign]sub_copy2 = 'Invoicing is subject to terms and conditions which you can review <a href="%%=v([at sign]track)=%%">here</a>. <br /><br /> and the google link, not tracked appears. <br /><br /> I'm going to work on option #2 now Jun 25, 2018 at 3:01
  • Option 3 result is the same - the content populates but the RedirectTo doesn't seem to work. It's so strange because the link is placed using the RedirecTo(@link) so I'm unsure why the link gets populated but not tracked. Jun 25, 2018 at 3:17
  • found some convoluted duct tape method, but it does work. Edited Answer with details Jun 25, 2018 at 13:09

You must log in to answer this question.

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