You are here:
Content Syndication in the API
Reference for information regarding Email Studio content syndication in the API.
HTTPGet Command
Purpose
Include in the body of the email to pull content at the specified URL into the email at the time the email is sent. If the content is cached, the system includes the cached copy; otherwise, the system accesses the URL. Use this command to include subscriber-specific content in each email in the campaign.
If the syndicated content is not specific to the subscriber, use the Before;HTTPGet command.
Syntax
%%httpget "URL"%%
Arguments
URL
You have multiple ads on your web server, and you have a script that picks one randomly, so that each subscriber gets a randomly selected ad.
The web site address is https://www.example.com. The filename of the script you've written to generate custom web pages is getdata.pl, which uses the Email Studio attribute labeled Email Address to determine which page to display. You enter this code in the email body at the point where the web page content appears:
%%httpget
"https://www.example.com/cgi-bin/getdata.pl?id=[Email Address]"%%
When the email is generated, the application substitutes the subscriber's email address into the URL (for example: https://www.example.com/cgibin/getdat...heirDomain.com). The content that appears in that location of the email body is the web page specific to that subscriber's email address.
Although the HTTPGet merge tag doesn’t require specific output from the URL, we recommend including a standard HTTP/1.0 200 OK status line, a Content-Type: text/plain or Content-Type: text/html line followed by an empty line, and then the content of the text to be inserted. For example, a Perl script would include code similar to the following:
print "HTTP/1.0 200 OK\r\n";
print "Content-Type: text/plain\r\n";
print
"\r\n";
print "Welcome to the Northern Trail
newsletter!";
This function works with HTTP on port 80 and HTTPS on port 443. Non-standard port assignments cause this function to fail.
HTTPGetWrap Command
Purpose
Include in the <a> tags of links in the syndicated content to track the links that appear in the content pulled into your emails with HTTPGet or the TreatAsContent() AMPscript function.
Syntax
<a href="httpgetwrap|URL">Click here</a>
Arguments
URL
Before;HTTPGet Command
Purpose
Include in the body of the email to pull content from the specified URL one time at the beginning of an email send to include in each email in the campaign. Use this command to save time over HTTPGet when you don't need the content pulled separately for each instance of the email. You can also use this command to obtain notification that an email send has begun. If the syndicated content is specific to the subscriber, use the HTTPGet command instead of this command.
Syntax
%%before;httpget "URL"%%
Arguments
URL
Including the Same Ad in Each Email
You have multiple ads on your web server, but you want every subscriber in a particular email send to see the same ad. The web site address is https://www.example.com, and the filename of the script that pulls the ad is getmailad.pl. Enter this code in the email body at the point where the ad appears:
%%before;httpget
"https://www.example.com/cgi-bin/getmailad.pl"%%
Requesting Notification that an Email Send has Begun
You've written a script that records the start time of the email send. The web site address where the script is located is https://www.example.com, and the filename of the script is recordevent.pl. You enter this code at the top of the email body:
%%before;httpget
"https://www.example.com/cgi-bin/recordevent.pl"%%
The system runs your script at the time the email send is processed. This command does not cause content to be added to the email body. The before;httpget command is processed outside of the subscriber context because it retrieves
content that is used in the email for all subscribers. Therefore, the only personalization that is valid in the URL query string is the JobID substitution. For example:
%%before;httpget
"https://www.example.com/cgibin/record....pl?id=[jobid]"%%
After;HTTPGet Command
Purpose
Include at the end of an email definition to perform an action one time at the end of an email campaign. This command does not include content in the body of the email. Use this command to provide notification to your CRM or CMS system that the email send completed.
Syntax
%%after;httpget "URL"%%
Arguments
URL
Requesting Notification that an Email Send has Completed
You've written a script that logs that an email send has been completed.
The web site address where the script is located is https://www.example.com and the filename of the script is logsentmessage.pl. You enter the following code at the end of the email body:
%%after;httpget
"https://www.example.com/cgi-bin/logsentmessage.pl"%%
The system runs your script at the conclusion of the email send. This command does not cause content to be added to the email body.
The after;httpget command is processed outside of the subscriber context because it is invoked one time after the send to all subscribers is complete. Therefore, the only personalization that is valid in the URL query string is the JobID substitution. For example:
%%after;httpget
"https://www.example.com/cgi-bin/logse...pl?jid=[jobid]"%%
Empty Return Handling Options
The HTTPGET call can succeed without an error but return no content. By default, the system assumes that there is no syndicated content relevant to the context of the email and continues the email send. You can override this default behavior with an optional flag.
Syntax
%%httpget[;EmptyReturnHandlingOption] "URL"%%
Or
%%before;httpget[;EmptyReturnHandlingOption] "URL"%%
Valid Values
- 0 (or none) - continue normal processing
- 1 - stop processing and set job status to error
- 2 (for a subscriber-level call) - skip the subscriber and continue the send
- 2 (for a before-level call) - stop the send and set job status to error
This flag is ignored for the After;HTTPGet command.
You have multiple ads on your web server, and you have a script that picks one randomly, so that each subscriber gets a randomly selected ad. If the script does not return an ad, you want the system to skip that subscriber and continue with the rest of the send.
The web site address is https://www.example.com, and the filename of the script is ad.pl, which is located in the cgi-binfolder. You enter the following code in the email body at the point where the ad appears:
%%httpget ; 2
"https://www.example.com/cgi-bin/ad.pl"%%
Error Handling
The best defense against content syndication errors is a good offense. Using AMPscript, you can prevalidate values being used for content syndication. If your page requires a query string value and errors if it doesn't receive it, you can check the value before the call occurring.
Potentially Dangerous
%%httpget
"http://adomain.com/newsletter/album?...umId=[albumid]"%%
In this content syndication call, albumid is required to return any content. If it isn't part of the request, it returns a server error.
A Better Approach
%%[ if length(albumid) > 0 then ]%% %%httpget
"http://adomain.com/newsletter/album?...umId=[albumid]"%% %%[ endif ]%%
This approach uses Manuscript to validate the data before executing the content syndication call. It doesn’t prevent rogue web server errors, but prevents data-related issues.

