Activate Experiment

Activate Experiment

The activateExperiment API is used to activate a FullStack A/B Test experiment for a given user. It evaluates whether the user qualifies for the experiment and assigns a variation accordingly.

Method

String variationName = pageSenseClient.activateExperiment(experimentName, userId, userAttributes);

Parameters:

Parameter

Type

Description

experimentName

String

The name of the experiment to activate.

userId

String

A unique identifier for the user.

userAttributes

HashMap<String, String>

A map of user attributes used for audience targeting and segmentation.


Return Value  

  • Returns the name of the allocated variation if the user qualifies for the Fullstack A/B experiment.

  • Returns null if the user does not meet the audience targeting criteria and fails to qualify for the FullStack A/B Experiment. 

Example code

import java.util.HashMap;

// Create the user attributes
HashMap<String, String> userAttributes = new HashMap<>();
userAttributes.put("Browser", "Chrome");
userAttributes.put("Device", "Desktop");
userAttributes.put("OS", "Windows 10");

// Activate the experiment
String variationName = pageSenseClient.activateExperiment(experimentName, userId, userAttributes);

// Define the behaviour for each variation
if ("Original".equals(variationName)) {
    // Code for 'Original'
} else if ("Variation 1".equals(variationName)) {
    // Code for 'Variation 1'
} else if ("Variation 2".equals(variationName)) {
    // Code for 'Variation 2'
} else if ("Variation 3".equals(variationName)) {
    // Code for 'Variation 3'
} else {
    // Code when the user is not part of the experiment
}


How the API works  

When the activateExperiment API is invoked, it follows a structured process to determine whether a variation should be allocated to the user. Below is a detailed breakdown of this process:

  1. Audience Targeting

The API first evaluates whether the user qualifies for the experiment based on audience targeting conditions defined during experiment configuration.
These conditions are typically based on user attributes such as browser, device type, operating system, or any custom user data passed in the userAttributes.

    • If the user’s attributes match the audience targeting conditions, the API proceeds to the next step.

    • If the user does not meet these conditions, the API immediately returns null, indicating that the user is not eligible to be included in the experiment.

  1. User Storage Service

Next, the API checks whether the User Storage Service is enabled. This service helps ensure consistency in variation assignments for the user by remembering previously assigned variations for users across multiple sessions.

    • If a variation has already been assigned and stored for the user in the User Storage Service, the API retrieves and returns that stored variation.

    • If no stored variation exists, the API proceeds to allocate a new variation using the bucketing logic described below.

  1. Hashing with MurmurHash
    The next step is to determine if the user qualifies for the experiment based on the experiment’s traffic allocation settings.

    • The API applies the MurmurHash algorithm to the user's ID (userId). This hashing algorithm consistently generates a unique numeric value between 0 and 9999 for each user ID, which serves as the user's hash value.

    • MurmurHash algorithm always generate the same hash value for the User ID for a given experiment across different sessions. This ensures deterministic and sticky variation assignment to the user for a given experiment.

  1. Variation Mapping
    Each variation within the experiment is assigned a specific range of hash values that corresponds to the variation’s allocated traffic percentage.

For example:

    • "Original" variation is assigned a hash range from 0–2000

    • "Variation 1" is assigned a hash range from 2001–4000

    • "Variation 2" is assigned a hash range from–6000 and so on.

These hash ranges are non-overlapping, ensuring a single variation is assigned per user and is Collectively exhaustive, covering the entire allocated traffic range of the experiment.

The API checks if the user’s hash value falls within any of these defined ranges:

    • If it does, the corresponding variation is allocated to the user.

    • If the hash value falls outside all assigned ranges, it means the user is not within the experiment’s traffic allocation, and null is returned.

  1. Tracking and Analytics

Once a variation is successfully allocated, the API sends the corresponding tracking data to the PageSense server. This data is used for analytics, reporting, and experiment performance evaluation.

  1. Return Value

    • If the user qualifies for the experiment and a variation is successfully allocated, the API returns the name of the variation allocated.

    • If the user fails to qualify for the experiment at any stage, the API returns null.

Using activateExperiment without user attributes  

The activateExperiment API may also be invoked without providing any user attributes. The following code demonstrates how to call the API without passing any user attribute parameters.

Method   

  1. String variationName = pageSenseClient.activateExperiment(experimentName, userId);

Parameter Details  

Parameter

Type

Description

experimentName

String

The name of the experiment to activate.

userId

String

A unique identifier for the user.


How the API Works: 

  1. In this version of the API, only the experiment name and user ID are required.

  2. The audience targeting step is still executed; however, since no user attributes are provided, the user will qualify only for the experiments where the audience targeting criteria is configured as “All Visitors.”

  3. If the experiment includes any additional audience targeting conditions—such as device type, location, or custom attributes—the user will automatically fail the qualification check due to the absence of use attribute data for evaluation.

  4. For experiments that allow “All Visitors,” the standard MurmurHash-based variation allocation logic is applied. If the user's hash value falls within the defined range of any variation, that variation is allocated, and the API returns the name of the assigned variation.

  5. If the user's hash value falls outside all defined variation ranges—due to the experiment’s traffic allocation configuration—no variation is allocated, and the API returns null.

We hope this documentation helps make the process easy for you. Please feel free to reach out to us anytime by dropping an email to support@zohopagesense.com if you need more explanation or have any questions.

      Create. Review. Publish.

      Write, edit, collaborate on, and publish documents to different content management platforms.

      Get Started Now


        Access your files securely from anywhere

          Zoho CRM Training Programs

          Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

          Zoho CRM Training
            Redefine the way you work
            with Zoho Workplace

              Zoho DataPrep Personalized Demo

              If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

              Zoho CRM Training

                Create, share, and deliver

                beautiful slides from anywhere.

                Get Started Now


                  Zoho Sign now offers specialized one-on-one training for both administrators and developers.

                  BOOK A SESSION







                              Quick LinksWorkflow AutomationData Collection
                              Web FormsRetailOnline Data Collection Tool
                              Embeddable FormsBankingBegin Data Collection
                              Interactive FormsWorkplaceData Collection App
                              CRM FormsCustomer ServiceForms for Solopreneurs
                              Digital FormsMarketingForms for Small Business
                              HTML FormsEducationForms for Enterprise
                              Contact FormsE-commerceForms for any business
                              Lead Generation FormsHealthcareForms for Startups
                              Wordpress FormsCustomer onboardingForms for Small Business
                              No Code FormsConstructionRSVP tool for holidays
                              Free FormsTravelFeatures for Order Forms
                              Prefill FormsNon-Profit
                              Forms for Government
                              Intake FormsLegal
                              Mobile App
                              Form DesignerHR
                              Mobile Forms
                              Card FormsFoodOffline Forms
                              Assign FormsPhotographyMobile Forms Features
                              Translate FormsReal EstateKiosk in Mobile Forms
                              Electronic FormsInsurance
                              Drag & drop form builder

                              Notification Emails for FormsAlternativesSecurity & Compliance
                              Holiday FormsGoogle Forms alternative GDPR
                              Form to PDFJotform alternativeHIPAA Forms
                              Email FormsWufoo alternativeEncrypted Forms
                              Accessible FormsTypeform alternativeSecure Forms

                              WCAG

                                          Create. Review. Publish.

                                          Write, edit, collaborate on, and publish documents to different content management platforms.

                                          Get Started Now






                                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                                Manage your brands on social media

                                                                  Use cases

                                                                  Make the most of Zoho Desk with the use cases.

                                                                   
                                                                    

                                                                  eBooks

                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                                   
                                                                    

                                                                  Videos

                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                                   
                                                                    

                                                                  Webinar

                                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                                   
                                                                    
                                                                  • Desk Community Learning Series


                                                                  • Meetups


                                                                  • Ask the Experts


                                                                  • Kbase


                                                                  • Resources


                                                                  • Glossary


                                                                  • Desk Marketplace


                                                                  • MVP Corner



                                                                    Zoho Sheet Resources

                                                                     

                                                                        Zoho Forms Resources


                                                                          Secure your business
                                                                          communication with Zoho Mail


                                                                          Mail on the move with
                                                                          Zoho Mail mobile application

                                                                            Stay on top of your schedule
                                                                            at all times


                                                                            Carry your calendar with you
                                                                            Anytime, anywhere




                                                                                  Zoho Sign Resources

                                                                                    Sign, Paperless!

                                                                                    Sign and send business documents on the go!

                                                                                    Get Started Now




                                                                                            Zoho TeamInbox Resources





                                                                                                      Zoho DataPrep Demo

                                                                                                      Get a personalized demo or POC

                                                                                                      REGISTER NOW


                                                                                                        Design. Discuss. Deliver.

                                                                                                        Create visually engaging stories with Zoho Show.

                                                                                                        Get Started Now









                                                                                                                            • Related Articles

                                                                                                                            • Activate Experiment

                                                                                                                              The ActivateExperiment API is used to activate a FullStack A/B Test experiment for a given user. It evaluates whether the user qualifies for the experiment and assigns a variation accordingly. Using ActivateExperiment with user attributes Method ...
                                                                                                                            • Different experiment methods used in PageSense

                                                                                                                              Though A/B (or Split URL) testing appears simple—comparing one page against another, to see which performs better—figuring out whether your test results actually mean anything specific is complicated. And for marketers and business owners, ...
                                                                                                                            • Share experiment reports with others

                                                                                                                              You can share the test report with your friends or colleagues as email attachment links right from within PageSense. You can also secure your shared reports with passwords to restrict them to specific users, and further set an expiration date to make ...
                                                                                                                            • Targeting specific audience segments in your experiment

                                                                                                                              Audience segmentation in PageSense typically means dividing or grouping website visitors into subgroups and subcategories based on a common set of characteristics, behavior, needs, and values. For example, you can segment users based on the device ...
                                                                                                                            • Setup triggers for your experiment in PageSense

                                                                                                                              In PageSense, you can create and launch different types of polls and pop-ups to grab the attention of visitors coming to your site. Even though these on-site messages are a powerful way to kindle your audience's interest towards your brand, if they ...
                                                                                                                              Wherever you are is as good as
                                                                                                                              your workplace

                                                                                                                                Resources

                                                                                                                                Videos

                                                                                                                                Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                                eBooks

                                                                                                                                Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                                Webinars

                                                                                                                                Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                                CRM Tips

                                                                                                                                Make the most of Zoho CRM with these useful tips.



                                                                                                                                  Zoho Show Resources