Tag expressions

更新时间:
复制 MD 格式

Tag format

Mobile Push supports pushes to a single tag and to multiple tags:

  • For single-tag pushes, the value of TargetValue is a string that contains the name of the tag.

  • For multi-tag pushes, TargetValue must use a tag expression, as described below.

Tag expressions

When the push target is a tag (Target=TAG), you can use a tag expression in the TargetValue field to send pushes based on custom multi-tag conditions.

Syntax

A tag expression uses nested and combined conditional operators and tags to define complex relationships between multiple tags. The expression is written in JSON format.

Operators and tag objects are identified by different keywords in the JSON structure, as shown in the following table:

Keyword

Type

Meaning

and

Operator

Expresses an AND relationship. It can be applied to one or more sub-expressions or tags.

or

Operator

Expresses an OR relationship. It can be applied to one or more sub-expressions or tags.

not

Operator

Expresses a NOT relationship. It can only be applied to a single tag.

tag

Tag

A specific tag node that stores the name of a business tag.

Each tag corresponds to a key-value pair of KeyType and ClientKey. When the TagValue expression is parsed, the tag is not resolved to a final deviceId. Instead, it is resolved to the KeyType and ClientKey key-value pair to perform the operation and obtain the final result. The KeyType can be DEVICE, ACCOUNT, or ALIAS, which specifies whether the tag is attached to a device, an account, or an alias.

For example, for the expression TargetValue={"and": [{"tag": "tag1"}, {"tag": "tag2"}]}, the calculation logic is as follows:

lQLPJyEW4asc1VrNAyTNBmGwR4A0EQ9kZLYEVAVEu8DQAA_1633_804..png

Limits

  • Operator limits:

    • Maximum nesting depth for and and or operators: 2

    • Maximum number of operands for and and or operators: 10

    • Maximum number of tags: 50

    • Because the tag calculation does not operate on a universal set, the not operator cannot be used alone.

  • Push frequency limits:

    • Tag result set over 5 million: 2 times/day

    • Tag result set between 1 million and 5 million: 20 times/day

    • Tag result set between 100,000 and 1 million: 100 times/day

    • Tag result set under 100,000: No limit

  • If you require higher limits, submit a ticket.

Example

{
  "and": [
    {
      "tag": "male"
    }, {
      "not": {
        "tag": "post-90s"
      }
    }, {
      "or": [
        {
          "tag": "active"
        }, {
          "not": {
            "tag": "overseas"
          }
        }
      ]
    }
  ]
}

The preceding expression selects users who are tagged as male, not post-90s, and either active or not overseas.