Dynamic Script

You can write a script (a new language that Apxor has created which somewhat looks like Javascript) instead of plain text to substitute user and session properties that you have already logged to Apxor SDK or you can substitute a text element from your application, or hidden text that you set it as a keyed tag (apx_view_tag).

The Apxor Language

The Apxor language looks similar to Javascript with some modifications.

We assume every dynamic param that you want to substitute in a text is a pre-defined variable that you can create upfront in the Script dialogue that Apxor Dashboard provides to you.

We support the following operators and keywords as part of our language specification

Unary Operators

! (Negation)

Logical Operators

&& (Logical AND)

|| (Logical OR)

Mathematical Operators

+ (Arithmetic Addition)

- (Arithmetic Subtraction)

* (Arithmetic Multiplication)

/ (Arithmetic Division)

% (Arithmetic Modulo)

Comparison Operators

< (Less than)

<= (Less than or Equals)

> (Greater than)

>= (Greater than or Equals)

== (Equality)

!= (Not Equality)

contains (Checks if a string contains another string)

Keywords

httpGet, onSuccess, onError will be used to make a HTTP GET API call

format will be used to format a string

if, else will be used to write conditional evaluation

true, false boolean keywords

toInt will be helful to convert double/float values to integer

Examples

Note:

Assume the following variables are defined

  • UserName (User Property)

  • RewardPoints (User Property)

  • IsSubscribed (User Property)

  • Subscribed (API JSON response parameter user.is_subscribed)

  • Simple formatting of the string

format(
  "Hello {}. We are excited to give you {} reward points. You can see these points in the Rewards section:",
  UserName,
  toInt(RewardPoints)
);
  • Conditional Dynamic Text

if (!IsSubscribed && RewardPoints < 500) {
  format(
    "Hello {}, you are just {} points away to get free subscription",
    UserName,
    500 - RewardPoints
  )
} else {
  format("Hello {}, You are already subscribed", UserName)
}
  • API call

httpGet(format("https://your-server.com/your-api?userName={}", UserName))
  .onSuccess(() => {
    if (SubScribed) {
      format("Hello {}, you are already subscribed", UserName)
    } else {
      format("Hello {}, you are not subscribed yet", UserName)
    }
  })
  .onError(() => format("Something went wrong. Try again later"));

Last updated