ExactTarget has a very robust Triggered Send functionality available to its users. It allows users to simply trigger a static email, pass in dynamic fields to the email, or pass in the entire HTML content block. Taking things further some users wish to send in the entire HTML content block with ExactTargets dynamic scripting included. Now, this poses an immediate problem because when rendering the email by default ExactTarget simply outputs the content and does not evaluate the scripting within the HTML. Recently, I had a client ask for this functionality and were able to have the AMPScript evaluated, but one problem remained: they were losing their click tracking because links were not being wrapped. They did have RedirectTo() around all their links but to no avail.
After some trial and error I came up with the following solution that bends the ExactTarget rules:
%%[ SET @key = Concat(emailaddr,FORMAT(NOW(),"yyyyMMddHHmmtt")) ]%% %%=TreatAsContentArea(@key, HTML__Content)=%%
The first line of AMPScript is to generate a unique key for the TreatAsContentArea function. Traditionally, the TreatAsContentArea or TACA function is used to create a content area cache to improve the performance of an email send. Thus, each TACA has a unique key so that the cached content area can be retrieved. The number of cached content areas is limited to 250 per send so my solution isn’t the most performant when it comes to large sends because after the 250th send the content area is built in real-time. Likewise, each TACA call in this case is unique and will never be called from the cache. However, for our purposes it does render the links wrapped with the tracking code and because it is a triggered send we’re only sending a few emails at a time thus performance is not a major consideration.
The second line is simply the TreatAsContentArea call using the key that was generated in the first line. In this example, I’ve stored the HTML content in a data extension with column name HTML__Content. This solution should also work for the scenario where content containing AMPScript is being retrieved from a data extension as well since the the process is the same in calling the TACA function.