Feed a Send Log / Send History Data Extension automatically

Whatever the reason is, you may want to save the Sends history in a data extension. This may allow you to extract this data for an external BI tool, or save the HTML message associated to each user for each send, etc…

So the idea would be to place an AMPSCRIPT code in each of your emails. A best practice would be to create an HTML content, and re-use it in all your templates / messages, by referring to its ID:

Prepare your data extension

First, you should create the data extension dedicated to save the Send data. No need to explain this part, unless you ask for this :)

Create your script

The AMPSCRIPT code to be written should:

  • launch only when the email is sent (not previewed)
  • save the wanted fields to the data extension

Here it is, commented:

In order to create such a script, you may need information about:

How to save the HTML message for each user ?

Now, you can save any information you may want into your Data Extension. In other terms, you may use this data extension to save the HTML of the email that will be received by each recipient, including personalization. The ideal way to perform this is to retrieve the code of the web-page (aka ‘mirror’ page):

Here, we set an @HTML variable, that will retrieve the web page content via an HTTPGET function. This variable is then saved in the « HTML » field of the data extension.

Solve the « open count » issue

The drawback of using the HTTPGET function on the web page is that an OPEN will be counted at the time of the send. The code of the page is executed, so the open tag will be launched. In order to avoid counting an OPEN when the mirror page is called, you can use some Message Context conditions in order to only show the open counter when the context is the SEND or the VAWP (View As Web Page). This code has to be applied to all your emails containing the Send history feature:

This conditional OPEN counter will make the trick !

4 réflexions au sujet de « Feed a Send Log / Send History Data Extension automatically »

  1. hello Mathieu

    tres interressant, j’ai un question sur la code ?

    mais eje continue en anglais, because i want to spare you from my halting french!
    I have been including this script in all my email sends in exacttarget but i miss knowing what is its full function? And what exactly is the difference if you have it or you dont ?

    Does it enable you to track exactly when an email is being opened without having the need to click to download image ?

    thank you very much
    rab

    1. Hi Rabiah,
      no the sendlog only keeps track of the sends, not the opens not clicks. By itself, the sendlog is useless, but you can use it via queries in order to aggregate send information per period, for example, and calculate some frequency metrics about how often eacu user receives emails.

    1. Thanks Adam. The fact is that you cannot choose the Send Log data extension (only one for the Business Unit) when you activate the Send Logging via SFMC. Also, if you need to send additional fields to the existing ones, ampscript variables with the same name as your Send log data extension columns should be present in the email, so Ampscript may be necessary in this case.
      Let’s say the « default » Send Logging is perfect when you do not need additional information in your send log.

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *