0

I'm sending to a big list and it has groups of users set up as Data Extensions. I want to do some dynamic content at time of send based on if the user is in a particular Data Extension. There is some overlap but I can deal with that with if/else. I was thinking of doing something like this:

%%[ IF UserIsInDataExtension("London_users") THEN ]%%
(Content for London segment)
%%[ ELSEIF UserIsInDataExtension("Birmingham_users")]%$
(Content for Birmingham segment)
%%[ ELSEIF UserIsInDataExtension("Never_purchased")]%%
(Content for Never purchased segment)
%%[ELSE]%%
(default content)
%%[ END ]%%

Is there something like this in AMPScript , and if there's nothing exactly like this then can I do something which attempts a lookup from the Data Extension as a way of seeing if the user is in it?

1

Sounds like your best bet might be to use the Lookup() AMPScript function. For example:

%%[

var @lookupEmailAddress 
set @lookupEmailAddress = AttributeValue("emailaddr")
set @InLondonUsers = Lookup("London_users", "emailAddress", "emailAddress", @lookupEmailAddress)

]%%

%%[ if not empty(@InLondonUsers) then ]%%
(Content for London segment)
%%[ endif ]%%

Reference: AMPScript Lookup() Function

Lookup(S1, S2, S3, S4)

Returns specified value from a data extension.

Arguments

S1 - The name of the data extension from which to return the specified value

S2 - Name of column from which to return a value

S3 - Name of column to match on to identify the row that contains the lookup value

S4 - Value to match S3 against

There are other ways to retrieve data from Data Extensions. You can find more code samples here on my blog.

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.