2

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?

3
  • Have you tried storing the html in data extensions and calling retrieving the values via LookUpRow()
    – 0xsegfault
    Dec 18, 2017 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, 2017 at 20:35

1 Answer 1

1

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

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

You must log in to answer this question.

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