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. But you might want to target a more complex and precise set of audiences, which cannot be done with the list of other available targeting options in the web application.
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.