1

I'd like to send an email to many Subscribers and retrieve content from an external URL (which is the same for each Subscriber), which will be used to personalise my email. Naturally, it's best practice to avoid making unnecessary requests (like the example below) as it may result in rate limiting and, well, it's just plain unnecessary.

%%[ /* How not to do it! */
var @url
set @url = HTTPGet('https://raw.githubusercontent.com/eliotharper/gtl-demo/master/featuredCases.json')
]%%

The solution? Content Syndication in the API. This is my new best friend. With Content Syndication, OMM will check if the content is cached, and if not then it will retrieve the external content, but if it's already been requested, then it will use the cached copy. Like this:

%%before;httpget 'https://raw.githubusercontent.com/eliotharper/gtl-demo/master/featuredCases.json'%%

This works well. However, I'd really like to get this to work in an AMPscript block, but I can't get this to work. I've tried this:

%%[
var @url
set @url = before;HTTPGet('https://raw.githubusercontent.com/eliotharper/gtl-demo/master/featuredCases.json')
]%%

and this:

%%[
var @url
set @url = before;httpget 'https://raw.githubusercontent.com/eliotharper/gtl-demo/master/featuredCases.json'
]%%

but in both instances, I get the error:

An unrecognized expression appears in a script block.

Does anyone know if there is a solution to this?

5
  • Is the content 100% identical for all users, or is there personalization in it that would make each area slightly different. E.g. First Name personalization that is filled externally? I know you stated it is the same, just want to verify Sep 6, 2017 at 12:40
  • It's the same static content for all Subscribers that could change daily, e.g. RSS feed that is rendered in an email. Sep 6, 2017 at 20:56
  • Check out the TreatAsContentArea ampscript function. I will try to put a more detailed answer when I can get to a computer - developer.salesforce.com/docs/… Sep 6, 2017 at 22:29
  • I took a look at that but can't get that to work with HTTPGet. If I use set @url = TreatAsContentArea(HTTPGet('https://myurl.com')) I get the error "Object reference not set to an instance of an object." Sep 6, 2017 at 23:50
  • Did you first include string "name" then your get? TreatAsContentArea requires a name first. Sep 6, 2017 at 23:58

1 Answer 1

2

You could try the TreatAsContentArea function. Which is different than TreatAsContent function.

Like so: Set @url = TreatAsContentArea("RSSFeed", HTTPGet('https://myurl.com'))

The TreatAsContentArea requires a string name and a content collect location. It also has an optional impression region declaration.

TreatAsContentArea(1, 2, 3)

1.) REQUIRED Key value used to identify the content specified in the second string. Use the same key to identify distinct text and HTML versions of the content, as the function treats a key in a text content as distinct from a key in a HTML context. The application processes all keys in a case-insensitive manner.

2.) REQUIRED Content stored for an email send under the key specified in the first string. Retrieve content using the HTTPGET() or Lookup() AMPscript functions

3.) Impression region name for the virtual >content area used for tracking purposes

By keeping a static content area name, it will keep loading the initially rendered block for the entire job, reducing server side processing time.

You must log in to answer this question.

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