Faith Hoefner
posted this on June 16, 2011 10:19
Custom Javascript can be used to enhance the functionality and combine complex sets of LiveBall advanced rules into a centralized, reusable script. We call them "scriptlets" and they can be added to LiveBall under the global Integration menu and the Server Scriptlets menu item. LiveBall advanced rules are used to run the scriptlet and base actions off of the Scriptlet’s results.
The power behind scriptlets is that you can write code for advanced, custom logic on your pages, store it centrally then plug it into creatives as needed!
1. Add Scriptlet(s) to your LiveBall console
You'll create your scriptlet outside of LiveBall and then add it to the library.
a. Navigate to Integration > Server Scriptlets
b. Click on +category and label a scriptlet category
c. Click on +Scriptlet and label the scriptlet
d. Paste custom Javascript into the scriptlet field
Note, use server-side Javascript (ECMAScript Version 3) to process data. The script should return a string or null.
e. Save
2. Use advanced rules to run your scriptlet(s) on your LiveBall pages
Now that you’re custom Javascript has been added to LiveBall, you can use advanced rules to trigger the script and base actions off of it’s response.
a. Navigate into the page you want your script to run on
b. Click on the “rules” button in the page editor bar if you want the script to run on page load. Click on the “+advanced rules” button if you want
the script to run upon form submission.
c. Add a rule condition to trigger the Scriptlet. If you want the script to run unconditionally upon page load or form submit, select “No conditions
required”.
d. Add the action labeled “Run server scriptlet” and select the script from the drop-down to the right.
e. To base action(s) from the scriptlet’s result(s), add a new advanced rule with the condition being “Server scriptlet result”, select the scriptlet and
input the result value.
f. Add an action to trigger based on the scriptlet’s result value.
Let’s say you added a scriptlet to LiveBall that calculates the respondent’s age based on a birth date value they input on a LiveBall form. You would run the scriptlet using form-level advanced rules. You could drive respondents under the age of eighteen, for example, to a page that explains they are not qualified to register.
Here’s an example of what your advanced rules might look like to accomplish this:
Condition: No conditions required
Action: Run server scriptlet - Age Calculation
Condition: Server scriptlet result - Age Calculation - less than – 19
Action: Go to next page – “Not qualified to register”
We've attached a server scriptlet to this post. This scriptlet identifies if the respondent is on a smart phone and assigns a true/false value accordingly. Using advanced rules, you can run the scriptlet and redirect respondents with a "true" value to a mobile-optimized page. The scriptlet also saves the smart phone type into a data collection field and tags the respondent, giving you heightened visibility into the devices your smart phone audience uses.
Please feel free to contact your account manager for support if you plan to leverage this powerful feature.