Loading

Use a Content Block containing AMPScript with Dynamic Sender Profiles

Udgivelsesdato: Aug 17, 2023
Beskrivelse
AMPScript can be used within a Code Snippet Content Block to determine the From Name and From Email based on subscriber data when using a Dynamic Sender Profile.
Løsning

Use Cases

Populate FromName and FromEmail directly from the Sendable Data Extension

Follow the steps to create code snippet in Content Builder. Sample AMPScript to input into the Code Snippet Content Block which assumes the source for the send has an attribute titled 'From_Name':
%%[ 
VAR @fromName 
SET @fromName = [From_Name] 
]%% 

%%=v(@fromName)=%%
Input the following in the Sender Profile From Name field:
%%=ContentBlockByKey('Snippet_From_Name')=%%
Populate FromName and FromEmail from within the AMPScript

FromName and FromEmail can be used dynamically to send from different Brands, Regions, Users or people within your Business that comes from the Dynamic Sender Profile.

Within your Sender Profile, you would utilise a Personalistion String (matching a field on the sending DE) or AMPScript function (ContentBlockByKey for example) to collect the data dynamically at send-time.

As an example, Salesforce would like to send Email Messages based on the Cloud they're related to. Each Data Extension they're sent to contains a Field named Cloud, with the value of the Cloud that will ensure a Dynamic FromName and FromEmail is utilised.

Note: The Cloud Field could also be used to dynamically set the Content of the Email too

Below is an example Data Extension and values Salesforce uses to send Email Message to.
SubscriberKeyEmailAddressFirstNameLastNameCloud
7635015d-1cb5-4482-a7b4-bddbb45a1edeexample1@example.comAstroNomicalSales
e84fd3dc-fcce-4aae-a324-b711dd5eb5a8example2@example.comAppythe BobcatService
d454b9ea-9bff-44b0-96bd-57402cd92640example3@example.comBlazethe WolfMarketing
ba438a49-b26b-4dff-9f4f-9c7604b669f0example4@example.comBrandythe FoxTrailhead
bc76d9fd-5cc5-4455-b4ac-360b278dfb38example5@example.comCloudythe GoatExperience

Upon sending the Email Message, the Sender Profile selected will call two Content Blocks via AMPScript that produce a FromName and FromEmail that's specific to each Cloud value from the sending Data Extension. For the FromName, the AMPScript code would look something like the below.
%%[

VAR @Cloud, @FromName, @FromEmail
SET @Cloud = Cloud

IF @Cloud == 'Sales' THEN 
SET @FromName = 'Sales Cloud'
SET @FromEmail = 'salescloud@salesforce.com'

ELSEIF @Cloud == 'Service' THEN
SET @FromName = 'Service Cloud'
SET @FromEmail = 'servicecloud@salesforce.com'

ELSEIF @Cloud == 'Marketing' THEN
SET @FromName = 'Marketing Cloud'
SET @FromEmail = 'marketingcloud@salesforce.com'

ELSEIF @Cloud == 'Trailhead' THEN
SET @FromName = 'Trailhead'
SET @FromEmail = 'trailhead@salesforce.com'

ELSEIF @Cloud == 'Experience' THEN
SET @FromName = 'Experience Cloud'
SET @FromEmail = 'experiencecloud@salesforce.com'

ELSE
SET @FromName = 'Salesforce'
SET @FromEmail = 'salesforce@salesforce.com'

ENDIF
]%%

%%=v(@FromName)=%%
You would need to duplicate the above content for the FromEmail variable to generate the FromEmail to then populate the Sender Profile.

You can also push this information to your SendLog Data Extension, you would need to create two new fields; one for the FromName, the second for FromEmail. Ensure the field name matches the Personalisation String or Content Block AMPScript.
 
Vidensartikelnummer

000381240

 
Indlæser
Salesforce Help | Article