0

I have an account that requires the same AMPScript be included in the header of each email deployed.

Instead of relying on each person to add the right AMPScript when coding emails, I'd like to set up an external source, such as a content area, that contains the proper AMPScript and then call this source in each email. This would reduce the amount of coded added to each email and make changes easier as only one location would need updating instead of multiple.

The content area idea didn't appear to work. Is this possible? Does anyone have ideas on how we might do this?

1

You can store the AMPScript in a content area. Another option is to use email templates and include the common AMPScript code as part of the email template. If you store the AMPScript in content areas, you would use the ContentArea or ContentAreaByName AMPScript functions to bring the code into the email.

The online help shows examples of calling these functions inline. But, you can also wrap the calls with an output function if you are wanting to return the results to a variable.

%%=ContentAreaByName("NameOfContentArea")=%%

or

%%[
    var @str
    set @str = output(ContentAreaByName("NameOfContentArea"))
]%%
%%=TreatAsContent(@str)=%%

I hope this helps. If you continue to have issues, please provide a code sample. I can help troubleshoot further.

|improve this answer|||||
  • Something to keep in mind when using Content Areas in Templates... If you make a change to a Content Area, it's live immediately, even if the Template changes have not been republished. – Adam Spriggs Jul 7 '15 at 15:56
  • so, if I wanted to take the following code – Jeni Harmon Jul 8 '15 at 19:35
0

so, WHAT IT IS NOW: %%[ /*Assign Test_cd */ set @tmrowset = lookuprows("ent.TestMatrixKeys","template", @template, "creative_flag", @creative_flag, "cluster_cd", @cluster_cd) if rowcount(@tmrowset) > 0 then set @tmrow = row(@tmrowset,1) Set @segment_cd = field(@tmrow, "segment_cd") Set @test_cd = field(@tmrow, "test_cd") else endif ]%% would become WHAT IT WOULD BE WITH THE TEST CD ABOVE MOVED TO TestCode CONTENT AREA: %%[ output(ContentAreaByName("TestCode")) ]%%

I tried moveing the ampscript to the content area previously and was only able to pull it in if the call was outside of the %%[]%%

|improve this answer|||||
  • What if you try: %%=ContentAreaByName("NameOfContentArea")=%% – David Devoy Aug 24 '15 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.