I am using dynamic content with rules in my email sends. Is it possible to use ampscript to log which content blocks a given customer has been exposed to?

I've trying to figure something out using insertDE, but I am stuck and getting no where.


If i have a email with


at the time of sent.

Then I want that data to be stored in a DE like:

Subscriberkey Block_ID
ABC 151991, 90385

Or like this:

Subscriberkey Block_ID
ABC 151991
ABC 90385
  • It would be easier to replicate the rules you are have set for Dynamic Content in the AMPscript Lookup function and then based on how rules would resolve, use InsertDE function with hardcoded Block_ID value.
    – Niko
    Commented Sep 7, 2021 at 9:16
  • I am hardcoding the InsertDE within each content block and it works fine. However I need to set the blockID manually each time. Do you know if there is a way to set the blockID automatic like I can set the email name with "emailname_"
    – Martin Ho
    Commented Sep 7, 2021 at 9:28

1 Answer 1


If you have a maximum number of content blocks, let's say 5, then I think below would be your best bet for handling a log of the blocks you use for each subscriber:

  /* set content block values */
  SET @Block1 = 12345
  SET @Block2 = 23456
  SET @Block3 = 34567
  SET @Block4 = 45678
  SET @Block5 = 56789

  /* example of calling a content block */


  /* Push info into Log */

  SET @insert = InsertDE('logDE','SubscriberKey',_subscriberkey, 'Job', jobid, 'emailname', _emailname, 'Block1',@Block1, 'Block2',@Block2,'Block3',@Block3,'Block4',@Block4,'Block5',@Block5,'InsertDate',NOW())

This will then push the corresponding blocks into a DE that will have 3 primary keys (Subscriberkey, Job, and EmailName) which will allow you to collect via multiple sends into the same DE and help separate between sends if you send to same email multiple times.

Columns for your DE:

SubscriberKey | Job  | EmailName | Block1   | Block2   | Block3   | Block4   | Block5   | InsertDate
 Pkey         | Pkey | Pkey      | Nullable | Nullable | Nullable | Nullable | Nullable | Nullable 

There are other options utilizing dynamic variable creations that can be done, but the level of processing and complexity for this may be higher than the value they offer.

You must log in to answer this question.

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