Data Cloud から SFMC にセグメントをアクティブ化するときに、アクティブ化の一環として関連する属性を含めることができます。セグメント公開時に、生成されたデータエクステンションに関連オブジェクトのフィールドが JSON 形式で保存されます。この動作は同じ登録者キーの複数の関連する値が存在する場合に、値が重複しないようにすることを意図しています。
メールでこの関連属性値を使用するには、AmpScript を使用して JSON データを解析し、必要なフィールドを抽出します。抽出した値はビジネス要件に応じて、動的にメールのコンテンツに挿入できます。
以下は JSON データを解析し、抽出した値をメールで使用する方法を示した AmpScript のコードスニペットのサンプルです。それぞれの使用事例とフィールド名に合わせて、このコードを修正してください。
%%[
/* 変数を宣言する */
var @subscriberKey, @jsonData, @rowSet, @rowCount, @currentRow, @fieldValue
var @imageURL1, @imageURL2, @imageURL3
/* 購読者キーと JSON データをデータエクステンションから取得する */
SET @subscriberKey = AttributeValue("SubscriberKey")
SET @jsonData = AttributeValue("RelatedFieldName") /* 'RelatedFieldName' を実際のフィールド名に置き換え */
/* JSON データを解析して反復のための行セットを作成する */
SET @rowSet = BuildRowsetFromJSON(@jsonData, "$.[]", 0)
SET @rowCount = RowCount(@rowSet)
/* JSON データの各行を処理する */
IF @rowCount > 0 THEN
FOR @i = 1 TO @rowCount DO
SET @currentRow = Row(@rowSet, @i)
SET @fieldValue = Field(@currentRow, "YourFieldName") /* 'YourFieldName' を抽出するフィールドと置き換える */
/* 例: フィールド値を一致させて特定の URL またはコンテンツを割り当てる */
IF @fieldValue == "Condition1" THEN
SET @imageURL1 = "https://your-image-url-1.com" /* 自社 URL に置き換える*/
ENDIF
IF @fieldValue == "Condition2" THEN
SET @imageURL2 = "https://your-image-url-2.com" /* 自社 URL に置き換える */
ENDIF
IF @fieldValue == "Condition3" THEN
SET @imageURL3 = "https://your-image-url-3.com" /* 自社 URL に置き換える */
ENDIF
NEXT @i
ENDIF
]%%
@subscriberKey: 登録者固有の ID です。@jsonData: データエクステンションの関連するフィールドから抽出した JSON データを保持します。@rowSet および @rowCount: JSON データの行の解析とカウントに使用されます。@currentRow および @fieldValue: 個々の行を処理し、特定のフィールド値を抽出します。RelatedFieldName」を JSON が含まれるデータエクステンションフィールドの名前に変更します。YourFieldName」を抽出する特定の JSON フィールドに変更します。Condition1、Condition2 など) と URL をビジネスロジックに合致するように変更します。このスクリプトは JSON データの各行に対して繰り返し実行され、必要なフィールドを抽出して、フィールドの値に基づきアクション (URL の割り当てなど) を実行します。
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.