Scriptlet: Server scriptlets for global sets of page rules & advanced functionality

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 Ion console

You’ll create your scriptlet outside of Ion and then add it to the library.

  1. Navigate to Libraries > Server Scriptlets
  2. Click green “New scriptlet category” and give it a label
  3. Click green “New scriptlet” button and label the scriptlet
  4. Paste or write 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.
  5. Save

2. Use rules to run your scriptlet(s) on your Ion pages

Now that your custom Javascript has been added to your console, you can use rules to trigger the script and base actions off of its response.

  1. Navigate to the page you want your script to run on
  2. Click on the “rules” button in the Page tab of your creative studio if you want the scriptlet to run on page load. If you would like the scriptlet to run on form submission, click the form’s submit button and then open the rules editor from within the Edit tab of your creative studio.
  3. Add a rule condition to trigger the scriptlet. If you want the scriptlet to run unconditionally upon page load or form submission, select “No conditions required”.
  4. Add the action labeled “Run server scriptlet” and select the scriptlet from the dropdown to the right.
  5. To base action(s) from the scriptlet’s result(s), add a new rule with the condition being “Server scriptlet result”, select the scriptlet, and input the result value.
  6. Add an action to trigger based on the scriptlet’s result value.

Let’s say you added a scriptlet to your console that calculates the respondent’s age based on a birth date value they input on an ion form. You would run the scriptlet using form-level rules. You could drive respondents under eighteen, for example, to a page explaining they are not qualified to register. Here’s an example of what your 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”

Mobile detection Scriptlet

We’ve attached a server scriptlet to this post. This scriptlet identifies if the respondent is on a smartphone and assigns a true/false value accordingly. Using rules, you can run the scriptlet and redirect respondents with a “true” value to a mobile-optimized page. The scriptlet also saves the smartphone type into a data collection field and tags the respondent, giving you heightened visibility into the devices your smartphone audience uses.

Please feel free to contact [email protected] for support if you have any questions about leveraging this powerful feature.
Share this:

Charmaine Yu is a UX/UI designer at Rock Content. With over a decade of experience in visual arts, Charmaine combines her eye for design with her love of UX to create memorable interactive content at Rock. With a UX design diploma from Brainstation, she spent the last couple of years learning and creating new content in the world of UX. Outside of work, you can find her cuddling her dog, at the next music festival or coach-potating at home.