0

Can I use Ampscript in a content area?

I am trying to say, IF Country = Australia then display this url else display another url.

I have added this to a content area but it keeps pulling in the other url for everything.

here is script.

<!-- %%[

Var @Country
Var @URL

Set @Country = Country

If @Country == "Australia" THEN

   Set @url = CONCAT("http://www.aaa.com/media/logos/australia.png")

ELSE
   Set @url = CONCAT("http://www.aaa.com/media/logos/other.png")

ENDIF

]%%
-->

<img src=%%=TreatAsContent(@URL)=%% />

1 Answer 1

2

Yes, but you'll need to wrap the output in a TreatAsContent() function to force the containing AMPScript to get evaluated.

%%[

  var @content
  set @content = contentareabyname("my contents\testContent") 

]%%
%%=treatascontent(@content)=%%

If it's just a URL, then you can just output it with the v() function:

%%[

  var @imageURL
  set @imageURL = "https://placeholdit.co//i/200x200"

]%%
<img src="%%=v(@imgURL)=%%"/>

You must log in to answer this question.

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