[SalesForce] Dynamic Sender Profile not working

I would like to automatically fill the "From Name" field of our sender profile.

Using AMPScript i created a new Sender Profile with %%=v(@FromName)=%% in my "From Name" field.

Then in my template-based email i added this code in the header:
%%[Var @FromName SET @FromName = "WR"]%% %%=v(@FromName)=%%

When i send this email my dynamic "From Name" doesn't get filled and Marketing Cloud uses the default name of my account even if the AMPScript is executed correctly because "WR" appears in the top of my email.

I've been looking for a solution but i couldn't find anything usefull. I already asked to Marketing Cloud support and they enabled everything was necessary to use the dynamic sender but they couldn't help me with the code.

Best Answer

The issue comes from the Sender Profile (SP) being processed prior to the email. This means that any variables set inside the email will not be rendered as they are set after the variable is called in the SP.

The logic you used above utilizing variables from the email works for subject line and preheader as they are processed after the email, so the variables are filled with any information set inside the email.

To counter this, I usually put the full ampscript logic inside of the Sender Profiles From Name and Address, followed by the variable call.

E.g.

%%[Var @FromName SET @FromName = "WR"]%% %%=v(@FromName)=%%

If your AMPscript is significant, it might be better to utilize a Content Block to house it and then call this block inside the SP.

e.g.

%%=ContentBlockbyKey("myContentBlock")=%%

Where the content block would output the @FromName Variable.

I usually utilize the raw code inside the SP as it keeps it all contained and simple.

You also can set an attribute (profile attribute on list or data extension field) and call that directly inside the SP.

Related Topic