Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

AMPScript で動的コンテンツを表示する

公開日: Feb 28, 2024
説明

※この記事は英語版を翻訳しており、一部機械翻訳を含むため内容は後日更新される可能性があります。最新の内容は英語版を参照してください。表示言語は画面右下の言語名から切り替えられます。
 

Marketing Cloud(マーケティング・クラウド) で動的コンテンツを表示するステップと例注: この情報は、Content Builder(コンテンツ・ビルダー)によって生成されたコンテンツには適用されません。 

解決策

動的コンテンツの表示

次の手順を実行します。 


1.テンプレートメールに次のコードを入れます (これにより、アカウントレベルのヘッダーとフッターを使用できるようになります)。 
 

%%[ Var @Content_A,@Content_B,@Content_C Set @Content_A = Test_A Set @Content_B = Test_B Set @Content_C = Test_C ]%% %%[IF @Content_A == 'Yes' THEN]%% %%=ContentAreaByName("my contents\dynamic\Content_A")=%% %%[ELSEIF @Content_B == 'Yes' THEN]%% %%=ContentAreaByName("my contents\dynamic\Content_B")=%% %%[ELSEIF @Content_C == 'Yes' THEN]%% %%=ContentAreaByName("my contents\dynamic\Content_C")=%% %%[ELSE]%% No content to render.... this would be a subscriber who meets none of the previous criteria..this would be the default content if you wanted to have default content %%[ENDIF]%%
 

2.「My Contents」フォルダに 3 つの ContentAreas (Content_A、Content_B、および Content_C) を作成します。

注: ContentArea のフルパスは、ContentAreaByName() 関数で指定するため、「my contents\dynamic\Content_C」は、「My Contents」の下の「Dynamic」サブフォルダの下の Content_C です。HTML 内のコンテンツはシンプルにしてください (<H1>これはコンテンツ領域 A です</H1>)。これにより、基本的なコンテンツで関数をテストできます。 

3.リストを作成し、上記のコードの各条件に対する値だけを持つ購読者を追加します。メール、ContentAreas、およびリストが用意できたら、テストリストでメールの送信プレビューを実行し、各購読者をプレビューしながら動的コンテンツの変更を確認できます。 



注: IF THEN ELSEIF の使用に基づいて、表示される ContentArea は属性に「Yes」の値が含まれる最初のものになります。 
 


コードの動作


最初のセクション

%%[ Var @Content_A,@Content_B,@Content_C Set @Content_A = Test_A Set @Content_B = Test_B Set @Content_C = Test_C ]%%

属性 Test_A、Test_B、および Test_C の値を格納する変数を作成し、それらに対応する属性値を設定します。「Set @Content_A = Test_A」は、変数 @Content_A に Test_A の値を設定することを意味します。  このタイプの AMPscript の詳細については、AMPScript 101 ドキュメントを参照してください。  

メインセクション

これは変数内の値を調べて、ContentAreaByName 関数を使用して ContentArea を挿入する IF ロジックです。現在、値が指定した範囲外になると、ELSE ブロックの情報が挿入されます。このロジックは微調整できます。 
 
%%[IF @Content_A == 'Yes' THEN]%% %%=ContentAreaByName("my contents\dynamic\Content_A")=%% %%[ELSEIF @Content_B == 'Yes' THEN]%% %%=ContentAreaByName("my contents\dynamic\Content_B")=%% %%[ELSEIF @Content_C == 'Yes' THEN]%% %%=ContentAreaByName("my contents\dynamic\Content_C")=%% %%[ELSE]%% No content to render.... this would be a subscriber who meets none of the previous criteria %%[ENDIF]%%
ナレッジ記事番号

000386274

 
読み込み中
Salesforce Help | Article