What does the custom script do?

The Optibase custom script is a JavaScript snippet that powers all live testing and tracking on your website.

When a user loads a page with the script installed, it handles everything from assigning variants to tracking conversions — all in real time.


Core Functions

1. Checks for active tests

On every page load, the script calls the Optibase server to:

  • Check which tests are currently active

  • Determine which tests apply to the current URL, user, and conditions (e.g. geo, browser, OS)


2. Handles A/B Tests

For A/B Tests, the script:

  • Scans the page for elements with data-optibase-test-id and data-optibase-variant-id attributes

  • Randomly selects one eligible variant per test

  • Reveals the selected variant by removing style="display:none" from the element

  • Removes all other variants from the DOM to prevent flicker or duplication

Tip: Only the Main Variant should be visible by default. All others should be hidden with display:none.


3. Handles Split Tests

For Split Tests, the script:

  • Examines the current URL to check if it matches an entry variant

  • If the test is eligible and active, it decides whether to:

    • Keep the user on the current page

    • Redirect the user to a different variant URL

If a redirect happens, it appends the following URL parameters:

  • splitTestId

  • splitVariantId

This helps the script on the new page recognize the test context.


4. Tracks Conversions

The script automatically detects:

  • Click-based conversions (data-optibase-click-conversion-id)

  • Submit-based conversions (data-optibase-submit-conversion-id)

It attaches event listeners to the matching elements. When triggered, a Conversion Event is sent to the server and attributed to:

  • The current page’s Split Test (if active)

  • All A/B Test elements the user has seen


5. Tracks Page Views

After tests are applied, the script sends a Page View to the server for:

  • The current page (if it’s part of a Split Test)

  • All A/B Test variants that were shown

Page Views do not count toward your monthly limit if:

  • There are no active or eligible tests on the page


Debugging and Controls

Enable Debug Mode

You can enable debug mode by adding this to the end of your URL:

?optibaseEnableDebugMode

This permanently enables debug mode in your browser. You’ll see detailed logs in the browser console showing what the script is doing step-by-step.

To disable it, use:

?optibaseDisableDebugMode


Disable the Script

To disable all Optibase testing and tracking in your browser, add:

?optibaseDisableScript

This prevents:

  • A/B or Split Tests from being applied

  • Any Conversion Events from being sent

To re-enable the script, use:

?optibaseEnableScript

These changes are local to your current browser and persist until manually reversed.


Summary

The custom Optibase script is the engine behind all live testing and tracking. It:

  • Determines which tests apply

  • Chooses and displays the correct variants

  • Tracks user interactions and conversions

  • Handles redirects for split tests

  • Sends all relevant data to the Optibase platform

Without the script, no tests will run and no conversions will be tracked.

Last updated