Skip to content

演算子

Liquid は、条件文で使用できる多くの 演算子 をサポートしています。このページでは、Liquidがサポートしているオペレータをカバーし、メッセージングでそれらをどのように使用できるかのユースケースを提供する。

この表は、サポートされている演算子の一覧である。かっこはLiquidでは無効な文字であり、タグが機能しないことに注意。

チュートリアル

いくつかのチュートリアルを通して、マーケティングキャンペーンにこれらのオペレーターを使う方法を学んでいこう:

整数カスタム属性でメッセージを選択する。

購入したユーザーまたは購入していないユーザーに、パーソナライズされたプロモーション割引を含むプッシュ通知を送信しましょう。プッシュ通知では、total_spend という整数のカスタム属性を使用して、ユーザーの合計金額をチェックします。

  1. greater than (>) 演算子を使用して条件文を書き、ユーザーの合計金額が0 より大きいかどうかをチェックします。これは、ユーザーが購入したことを示します。次に、これらのユーザーに送信するメッセージを作成します。
1
2
{% if {{custom_attribute.${total_spend}}} >0 %}
Surprise! We added a 15% discount code to your account that automatically applies to your next order.

2.{% else %} タグを追加し、合計金額が 0 と等しいか、存在しないユーザーをキャプチャします。次に、これらのユーザーに送信するメッセージを作成します。

1
2
{% else %}
Need a sign to update your wardrobe? We added a 15% discount code to your account that will automatically apply to your first order.

3.{% endif %} タグで条件ロジックを閉じる。

1
{% endif %}

チュートリアルの完全なLiquidコードを含むプッシュ通知コンポーザー。

完全な Liquid コード
1
2
3
4
5
{% if {{custom_attribute.${total_spend}}} >0 %}
Surprise! We added a 15% discount code to your account that automatically applies to your next order.
{% else %}
Need a sign to update your wardrobe? We added a 15% discount code to your account that will automatically apply to your first order.
{% endif %}

これで、ユーザーの “Total Spend “カスタム属性が0 より大きい場合、メッセージが表示される:

1
Surprise! We added a 15% discount code to your account that automatically applies to your next order.

もしユーザーの “Total Spend “カスタム属性が存在しなかったり、0 と等しい場合、以下のメッセージが表示される:

1
Need a sign to update your wardrobe? We added a 15% discount code to your account that will automatically apply to your first order.

文字列カスタム属性でメッセージを選ぶ

ユーザーにプッシュ通知を送り、各ユーザーが最近プレイしたゲームに基づいてメッセージをパーソナライズさせよう。これは、recent_game という文字列カスタム属性を使用して、ユーザーが最後にプレーしたゲームをチェックします。

  1. 等号 (==) 演算子を使った条件文を書き、ユーザーの最近のゲームが「Awkward Dinner Party」であるかどうかをチェックする。次に、これらのユーザーに送信するメッセージを作成します。
1
2
{% if {{custom_attribute.${recent_game}}} == 'Awkward Dinner Party' %}
You are formally invited to our next dinner party. Log on next week for another round of delectable dishes and curious conversations.

2.elsif タグと equals (==) 演算子を使用して、ユーザーの最新のゲームがProxy War 3 であるかどうかをチェックする:War of Thirst』のフィードバックを測定する。次に、これらのユーザーに送信するメッセージを作成します。

1
2
{% elsif {{custom_attribute.${recent_game}}} == 'Proxy War 3: War of Thirst' %}
Your fleet awaits your next orders. Log on when you're ready to rejoin the war for hydration.

3.elsif タグと does not equal (!=) および “and” (&&) 演算子を使用して、ユーザーが最近のゲームを持っているかどうか (値が空白でないことを意味する)、そのゲームがAwkward Dinner Party または Proxy War 3 でないことをチェックします:War of Thirst』のフィードバックを測定する。次に、これらのユーザーに送信するメッセージを作成します。

1
2
{% elsif {{custom_attribute.${recent_game}}} != blank && 'Awkward Dinner Party' or 'Proxy War 3: War of Thirst' %}
Limited Time Deal! Get 15% off our best-selling classics!

4.最近のゲームを持っていないユーザーをキャプチャするには{% else %} タグを追加します。次に、これらのユーザーに送信するメッセージを作成します。

1
2
{% else %}
Hey! I've got a deal for you. Buy 2 of our newest releases and get 10% off!

5.{% endif %} タグで条件ロジックを閉じる。

1
{% endif %}
完全な Liquid コード
1
2
3
4
5
6
7
8
9
{% if {{custom_attribute.${recent_game}}} == 'Awkward Dinner Party' %}
You are formally invited to our next dinner party. Log on next week for another round of delectable dishes and curious conversations.
{% elsif {{custom_attribute.${recent_game}}} == 'Proxy War 3: War of Thirst' %}
Your fleet awaits your next orders. Log on when you're ready to rejoin the war for hydration.
{% elsif {{custom_attribute.${recent_game}}} != blank && 'Awkward Dinner Party' or 'Proxy War 3: War of Thirst' %}
Limited Time Deal! Get 15% off our best-selling classics!
{% else %}
Hey! I've got a deal for you. Buy 2 of our newest releases and get 10% off!
{% endif %}

チュートリアルの完全なLiquidコードを含むプッシュ通知コンポーザー。

さて、ユーザーが最後に『Awkward Dinner Party』をプレイした場合、このようなメッセージが表示される:

1
You are formally invited to our next dinner party. Log on next week for another round of delectable dishes and curious conversations.

ユーザーの直近のゲームがProxy War 3の場合:War of Thirst 、彼らはこのメッセージを受け取ります:

1
Your fleet awaits your next orders. Log on when you're ready to rejoin the war for hydration.

ユーザーが最近プレイしたゲームが『気まずい晩餐会』や『代理戦争3』でない場合:War of Thirst、彼らはこのメッセージを受け取ります:

1
Limited Time Deal! Get 15% off our best-selling classics!

もしユーザーがゲームをプレイしていなかったり、そのカスタム属性がプロファイルに存在しなかったりすると、このメッセージが表示される:

1
Hey! I've got a deal for you. Buy 2 of our newest releases and get 10% off!

位置に基づいてメッセージをアボートする

あらゆる条件に基づいてメッセージを中止することができます。ユーザーが指定された地域に住んでいない場合、プロモーションやショー、配信の対象にならない可能性があるため、メッセージを中止しよう。

  1. equals (==) 演算子を使った条件文を書いて、ユーザーのタイムゾーンがAmerica/Los_Angeles かどうかをチェックし、それらのユーザーに送信するメッセージを作成する。
1
2
{% if {{${time_zone}}} == 'America/Los_Angeles' %}
Stream now!

2.America/Los_Angeles タイムゾーン外のユーザーへのメッセージの送信を避けるには、{% else %}{% endif %} タグを{% abort_message () %} タグで囲みます。

1
2
3
{% else %}
{% abort_message () %}
{% endif %}
完全な Liquid コード
1
2
3
4
5
{% if {{${time_zone}}} =='America/Los_Angeles' %}
Stream now!
{% else %}
{% abort_message () %}
{% endif %}

チュートリアルの完全なLiquidコードを含むプッシュ通知コンポーザー。

また、接続コンテンツに基づいてメッセージをアボートすることもできます。

「このページはどの程度役に立ちましたか?」
New Stuff!