0

I am trying to figure out if I can use AMPScript in the body of an email to find out the name of the List or Data Extension the email is being sent to and then do something based on which condition is met. Does that make sense?

So basically, if I am sending an email and my Data Extension name is DE1 then do something in AMPScript. If it's DE2, do something different.

2
3

I think you're looking for the _DataSourceName personalization string.

This value captures any audience object sent to. This covers lists, data extensions, groups, and filters.

Usage:

%%[

if _DataSourceName == "DE1" then

  /* something for DE1 */

else

  /* something for DE2 */ 

endif

]%%

You may need to experiment with it if your send is every sent to more than one DE.

Update 2020-07-07

You can get a bunch of info about journey interactions via REST API. It'll give you all the details about the send context and email definition, etc. Technically, you could pull this data in an Automation with a Script Activity and store it in a DE. Similar to this, except with a REST call instead of WSProxy retrieve on the SOAP object.

8
  • Dude you are awesome. How come I couldn't find that in the docs? Is this kind of stuff listed anywhere?
    – garek007
    Jun 28 '17 at 21:15
  • 1
    The Personalization Strings and AMPScript Functions pages are my most frequently visited links. Jun 28 '17 at 21:21
  • Yes I looked there but did not see it.
    – garek007
    Jun 28 '17 at 21:24
  • 1
    @AdamSprings so this has been really helpful in the past. I found it doesn't work with Journeys. Do you have any experience with that? For some reason, in a journey you'd think it would reference the entry point DE, but it references All Subscribers
    – garek007
    Aug 3 '18 at 20:51
  • @garek007 I know it's a long shot, but were you able to figure out a way to get a reference to the entry point DE ? (working on a Journey too) Jul 7 '20 at 9:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.