During segment activation from Data 360 to SFMC, you can include related attributes as part of the activation. Upon publishing the segment, the generated data extension will store fields from the related objects in JSON format. This behavior is intentional to avoid duplication of values for the same subscriber key when multiple related values exist.
To use these related attribute values in your emails, you can leverage AmpScript to parse the JSON data and extract the required fields. The extracted values can then be dynamically inserted into the email content based on your business requirements.
Below is a sample AmpScript code snippet that demonstrates how to parse JSON data and use the extracted values in an email. You can modify this code based on your specific use case and field names.
%%[
/* Declare variables */
var @subscriberKey, @jsonData, @rowSet, @rowCount, @currentRow, @fieldValue
var @imageURL1, @imageURL2, @imageURL3
/* Get subscriber key and JSON data from the data extension */
SET @subscriberKey = AttributeValue("SubscriberKey")
SET @jsonData = AttributeValue("RelatedFieldName") /* Replace 'RelatedFieldName' with the actual field name */
/* Parse the JSON data to create a rowset for iteration */
SET @rowSet = BuildRowsetFromJSON(@jsonData, "$.[]", 0)
SET @rowCount = RowCount(@rowSet)
/* Process each row in the JSON data */
IF @rowCount > 0 THEN
FOR @i = 1 TO @rowCount DO
SET @currentRow = Row(@rowSet, @i)
SET @fieldValue = Field(@currentRow, "YourFieldName") /* Replace 'YourFieldName' with the field you want to extract */
/* Example: Match field value to assign specific URLs or content */
IF @fieldValue == "Condition1" THEN
SET @imageURL1 = "https://your-image-url-1.com" /* Replace with your URL */
ENDIF
IF @fieldValue == "Condition2" THEN
SET @imageURL2 = "https://your-image-url-2.com" /* Replace with your URL */
ENDIF
IF @fieldValue == "Condition3" THEN
SET @imageURL3 = "https://your-image-url-3.com" /* Replace with your URL */
ENDIF
NEXT @i
ENDIF
]%%
@subscriberKey: Represents the unique identifier for the subscriber.@jsonData: Holds the JSON data extracted from the related field in the data extension.@rowSet and @rowCount: Used to parse and count rows in the JSON data.@currentRow and @fieldValue: Handle individual rows and extract specific field values.RelatedFieldName with the name of the data extension field containing JSON.YourFieldName with the specific JSON field you want to extract.Condition1, Condition2, etc.) and URLs to match your business logic.The script iterates through each row in the JSON data, extracts the required field, and performs actions (e.g., assigns URLs) based on the field's value.
003960855

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.