1

I'm trying to set the value of a variable to be a complete table housing all the HTML I need to build a clickable image, title, and button. For brevity, I currently have:

VAR @featureTitle
SET @featuretitle = "<table width="100%" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center">
        <a href="http://www.example.com/url" title="Name of Article" alias="Name of Article" conversion="false" data-linkto="http://">
            Name of Article
        </a>
    </td>
  </tr>
</table>"
]%%

However, it doesn't show up. It doesn't render any the content if I include the style attribute or an <a> tag. It seems that I can only set small and simple HTML tags like:

VAR @featureTitle
SET @featuretitle = "<h1>Name of Article</h1>"
]%%

How can I achieve the results I'm looking for, or anything similar?

  • Have you tried storing the html in data extensions and calling retrieving the values via LookUpRow() – Samuel Dare Dec 18 '17 at 23:15
  • I haven't tried moving the HTML into the Data Extensions because I want to remove as much content as I can. I already have a lot in there. I saw the link but I can only get a small amount of HTML to work. I'm going to look into ContentArea( ). But how do I use them? – Josue A. Dec 19 '17 at 20:35
0

The problem you'll have when setting a block of html a variable is that the double-quotes in your string are escaping your 'set' statement e.g. set @me = "<a href="something" ...."

You could try distinguishing your set quotations as single quotes i.e. set @me = '<a href="something" ...'

But it's rather messy and cumbersome maintaining your code in this way.

Probably the best way would be to create a Content Box with the snippet of HTML you want (suggest using Content Builder if you aren't already) and set the External Key for your Content Block.

You can then set/call your content block using :

Set @me = ContentBlockbyKey("myContentBlockKey") 

This way, if you ever want to simply update your html, you can just edit your content block and avoid messing about with your ampscript

Also, if you are using hyperlinks in ampscript, you are best wrapping them in RedirectTo() if you want those hyperlinks tracked. This is because ampscript is processed separately from the URL processor - so a raw URLs in your ampscript won't be processed as a redirect / tracking URL

  • Thanks for the help. The single quote was the solution I was looking for. – Josue A. Jan 8 '18 at 14:48

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.