0

I need some AMPscript that will serve up a different first name based on the email that a given Journey is being targeted at.

I have three groups of people:
Mothers
Fathers
Guardians

Their firstname fields are:
Mother_First_Name__c
Father_First_Name__c
Guardian_First_Name__c

Their email fields are:
Mother_Email__c
Father_Email__c
Guardian_Email__c

At the moment I'm using three separate blocks of AMPscript to populate these names, however I'm quickly realizing that this is necessitating three of everything as my campaigns are being built out!

I need some AMPscript to say IF Journey is targeted at Mother_Email__c then populate Mother_First_Name__c in the name field.

Is that even possible?

Thanks in advance!

  • Im not sure if I understand the problem. If you have the Emails for specifig target groups, like mothers, you can do something like SET @firstName = Mother_First_Name__c inside your email template or email and then just continue using that variable. Maybe you can specify where do you need what information. You need it for personalization in the emails or something else? – DonL Dec 2 '19 at 15:31
  • The problem is that I need to have three different versions of the AMPscript which then go into three difference versions of the emails. I'd like to use just one. To do that though, I need the AMPscript to reference who the email is being sent to in the Journey it's being associated with. – Thomas Hockey Dec 2 '19 at 15:33
0

You can probably create a 'flag' at the top of your email to determine which is the current version (Mother, Father, Guardian) and then from there systematically pull only the matching var through concat.

Basically, one time at the top of the email you do something like:

%%[
SET @Mother =   AttributeValue("Mother_Email__c")
SET @Father =   AttributeValue("Father_Email__c")
SET @Guardian = AttributeValue("Guardian_Email__c")

if @Mother then
  SET @prefix = "Mother_"
elseif @Father then
  SET @prefix = "Father_"
elseif @Guardian then
  SET @prefix = "Guardian_"
else
  RaiseError()
endif    
]%%

and then since the other two won't exist in the associated record, you then have your flag that sets which prefix to use on your future attributes.

For instance, to pull first name, you just need to do:

SET @firstName = AttributeValue(CONCAT(@prefix,'First_Name__c'))

This will then (if flag is Mother) pull the attribute Mother_First_Name__c from the sendable data source. Or if it is flagged as Father, it will pull Father_First_Name__c. Etc.

This can also be used in a lookup, for instance:

SET @firstName = Lookup(CONCAT(@prefix,'DE'), CONCAT(@prefix,'First_Name__c'), CONCAT(@prefix,'Email__c'), emailaddr)

and that will do a lookup to the Mother_DE to pull the Mother_First_Name__c field matching on the foreign key of Mother_Email__c is equal to emailaddr (which will pull the current sendable email address).

| improve this answer | |
0

Yes, it's possible:

  • All of the email fields can be replaced by the personalization string %%emailaddr%% which will return the email address of the recipient.
  • You will not know which of the 3 email fields was used, so you need to perform a series of lookups to your synchronized data extension trying to return the name (of the mother, father or guardian) based on the associated email column and the personalization string as the value to match string against.
  • After that you need to check if any of the lookups returned a value - you can do this with the Empty function.
  • If any of the values is not empty (the function returns false), you can assign it to a single name variable that you can use.
| improve this answer | |
  • Brilliant, thank you. Would you be able to share the bare bones of what that AMPscript would look like please? – Thomas Hockey Dec 2 '19 at 16:39

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.