An important thing to note here is that the code/condition you write must return a boolean value. If the condition returns true, the experiment will run for that visitor. If the condition returns false, the experiment will not run.
In the web application, targeting options let you define who and where your experiment should be targeting. However, sometimes you need to go beyond the standard targeting options to reach a more specific and complex set of audiences.
Go to MARKETING AUTOMATION > A/B Testing.
Choose an experiment and click Pause.
Click on the paused experiment to open it.
Click the Edit Experiment button.
Under the TARGETING tab > click ADD CUSTOM AUDIENCE
Case 1 - Running the experiment for a certain time period
Scenario: An e-commerce site wants to display a page containing exclusive offers to all the site’s visitors who enter the afternoon after 12 till midnight.
Case 2 - Running the experiment for logged-in visitors exclusively
Scenario: An online book store wants to target the experiment specifically to the logged-in visitors to display a page containing access to all their books’ premium collections.
Case 3 - Running the experiment for visitors with certain screen sizes
Scenario: An online ticket booking site has a responsive website and wants to target the audience who enter the site with specific screen sizes, like the one on a tab.