Pick winning variant for landing page CTA
[MAILPOET-5262]
This commit is contained in:
committed by
Aschepikov
parent
8394719806
commit
f5564aa50e
@ -1,88 +0,0 @@
|
|||||||
import { __ } from '@wordpress/i18n';
|
|
||||||
import { MailPoet } from 'mailpoet';
|
|
||||||
import {
|
|
||||||
Experiment,
|
|
||||||
Variant,
|
|
||||||
emitter,
|
|
||||||
experimentDebugger,
|
|
||||||
} from '@marvelapp/react-ab-test';
|
|
||||||
import { Button } from 'common';
|
|
||||||
import {
|
|
||||||
MailPoetTrackEvent,
|
|
||||||
CacheEventOptionSaveInStorage,
|
|
||||||
} from '../analytics-event';
|
|
||||||
import { redirectToWelcomeWizard } from './util';
|
|
||||||
|
|
||||||
const EXPERIMENT_NAME = 'landing_page_cta_display';
|
|
||||||
const VARIANT_BEGIN_SETUP = 'landing_page_cta_display_variant_begin_setup';
|
|
||||||
const VARIANT_GET_STARTED_FOR_FREE =
|
|
||||||
'landing_page_cta_display_variant_get_started_for_free';
|
|
||||||
|
|
||||||
// analytics permission is currently unavailable at this point
|
|
||||||
// we will save the event data and send them to mixpanel later
|
|
||||||
// details in MAILPOET-4972
|
|
||||||
|
|
||||||
// Called when the experiment is displayed to the user.
|
|
||||||
emitter.addPlayListener((experimentName, variantName) => {
|
|
||||||
MailPoetTrackEvent(
|
|
||||||
'Experiment Display',
|
|
||||||
{
|
|
||||||
experiment: experimentName,
|
|
||||||
variant: variantName,
|
|
||||||
},
|
|
||||||
CacheEventOptionSaveInStorage, // persist in local storage
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Called when a 'win' is emitted
|
|
||||||
emitter.addWinListener((experimentName, variantName) => {
|
|
||||||
MailPoetTrackEvent(
|
|
||||||
'Experiment Win',
|
|
||||||
{
|
|
||||||
experiment: experimentName,
|
|
||||||
variant: variantName,
|
|
||||||
},
|
|
||||||
CacheEventOptionSaveInStorage, // persist in local storage
|
|
||||||
redirectToWelcomeWizard, // callback
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Define variants in advance.
|
|
||||||
emitter.defineVariants(
|
|
||||||
EXPERIMENT_NAME,
|
|
||||||
[VARIANT_BEGIN_SETUP, VARIANT_GET_STARTED_FOR_FREE],
|
|
||||||
[50, 50],
|
|
||||||
);
|
|
||||||
|
|
||||||
experimentDebugger.setDebuggerAvailable(
|
|
||||||
MailPoet.FeaturesController.isSupported('landingpage_ab_test_debugger'),
|
|
||||||
);
|
|
||||||
experimentDebugger.enable();
|
|
||||||
|
|
||||||
function AbTestButton() {
|
|
||||||
return (
|
|
||||||
<Experiment name={EXPERIMENT_NAME}>
|
|
||||||
<Variant name={VARIANT_BEGIN_SETUP}>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
emitter.emitWin(EXPERIMENT_NAME);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{__('Begin setup', 'mailpoet')}
|
|
||||||
</Button>
|
|
||||||
</Variant>
|
|
||||||
<Variant name={VARIANT_GET_STARTED_FOR_FREE}>
|
|
||||||
<Button
|
|
||||||
onClick={() => {
|
|
||||||
emitter.emitWin(EXPERIMENT_NAME);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{__('Get started for free', 'mailpoet')}
|
|
||||||
</Button>
|
|
||||||
</Variant>
|
|
||||||
</Experiment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
AbTestButton.displayName = 'Landingpage Ab Test';
|
|
||||||
|
|
||||||
export { AbTestButton };
|
|
@ -1,6 +1,7 @@
|
|||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { Button } from 'common';
|
||||||
import { Heading } from 'common/typography/heading/heading';
|
import { Heading } from 'common/typography/heading/heading';
|
||||||
import { AbTestButton } from './ab-test-button';
|
import { redirectToWelcomeWizard } from './util';
|
||||||
|
|
||||||
function Footer() {
|
function Footer() {
|
||||||
return (
|
return (
|
||||||
@ -10,7 +11,9 @@ function Footer() {
|
|||||||
{' '}
|
{' '}
|
||||||
{__('Ready to start using MailPoet?', 'mailpoet')}{' '}
|
{__('Ready to start using MailPoet?', 'mailpoet')}{' '}
|
||||||
</Heading>
|
</Heading>
|
||||||
<AbTestButton />
|
<Button onClick={redirectToWelcomeWizard}>
|
||||||
|
{__('Begin setup', 'mailpoet')}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
|
import { Button } from 'common';
|
||||||
import { Heading } from 'common/typography/heading/heading';
|
import { Heading } from 'common/typography/heading/heading';
|
||||||
import { AbTestButton } from './ab-test-button';
|
import { redirectToWelcomeWizard } from './util';
|
||||||
|
|
||||||
function Header() {
|
function Header() {
|
||||||
return (
|
return (
|
||||||
@ -15,7 +16,9 @@ function Header() {
|
|||||||
'mailpoet',
|
'mailpoet',
|
||||||
)}
|
)}
|
||||||
</p>
|
</p>
|
||||||
<AbTestButton />
|
<Button onClick={redirectToWelcomeWizard}>
|
||||||
|
{__('Begin setup', 'mailpoet')}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
@ -5,7 +5,6 @@ namespace MailPoet\Features;
|
|||||||
use MailPoetVendor\Doctrine\DBAL\Exception\TableNotFoundException;
|
use MailPoetVendor\Doctrine\DBAL\Exception\TableNotFoundException;
|
||||||
|
|
||||||
class FeaturesController {
|
class FeaturesController {
|
||||||
const LANDINGPAGE_AB_TEST_DEBUGGER = 'landingpage_ab_test_debugger';
|
|
||||||
const FEATURE_BRAND_TEMPLATES = 'brand_templates';
|
const FEATURE_BRAND_TEMPLATES = 'brand_templates';
|
||||||
const GUTENBERG_EMAIL_EDITOR = 'gutenberg_email_editor';
|
const GUTENBERG_EMAIL_EDITOR = 'gutenberg_email_editor';
|
||||||
const MAILPOET_WOOCOMMERCE_MULTICHANNEL_INTEGRATION = 'mailpoet_woocommerce_multichannel_integration';
|
const MAILPOET_WOOCOMMERCE_MULTICHANNEL_INTEGRATION = 'mailpoet_woocommerce_multichannel_integration';
|
||||||
@ -13,7 +12,6 @@ class FeaturesController {
|
|||||||
// Define feature defaults in the array below in the following form:
|
// Define feature defaults in the array below in the following form:
|
||||||
// self::FEATURE_NAME_OF_FEATURE => true,
|
// self::FEATURE_NAME_OF_FEATURE => true,
|
||||||
private $defaults = [
|
private $defaults = [
|
||||||
self::LANDINGPAGE_AB_TEST_DEBUGGER => false,
|
|
||||||
self::FEATURE_BRAND_TEMPLATES => false,
|
self::FEATURE_BRAND_TEMPLATES => false,
|
||||||
self::GUTENBERG_EMAIL_EDITOR => false,
|
self::GUTENBERG_EMAIL_EDITOR => false,
|
||||||
self::MAILPOET_WOOCOMMERCE_MULTICHANNEL_INTEGRATION => false,
|
self::MAILPOET_WOOCOMMERCE_MULTICHANNEL_INTEGRATION => false,
|
||||||
|
@ -3,8 +3,6 @@
|
|||||||
namespace MailPoet\Test\Acceptance;
|
namespace MailPoet\Test\Acceptance;
|
||||||
|
|
||||||
use Facebook\WebDriver\WebDriverKeys;
|
use Facebook\WebDriver\WebDriverKeys;
|
||||||
use MailPoet\Features\FeaturesController;
|
|
||||||
use MailPoet\Test\DataFactories\Features;
|
|
||||||
use MailPoet\Test\DataFactories\Settings;
|
use MailPoet\Test\DataFactories\Settings;
|
||||||
|
|
||||||
class LandingpageBasicsCest {
|
class LandingpageBasicsCest {
|
||||||
@ -48,45 +46,11 @@ class LandingpageBasicsCest {
|
|||||||
$settings = new Settings();
|
$settings = new Settings();
|
||||||
$settings->withWelcomeWizard();
|
$settings->withWelcomeWizard();
|
||||||
|
|
||||||
(new Features())->withFeatureEnabled(FeaturesController::LANDINGPAGE_AB_TEST_DEBUGGER); // enable ab test debugger
|
|
||||||
|
|
||||||
$i->amOnMailpoetPage('Emails');
|
$i->amOnMailpoetPage('Emails');
|
||||||
$i->waitForText('Better email — without leaving WordPress');
|
$i->waitForText('Better email — without leaving WordPress');
|
||||||
|
|
||||||
$this->selectAbTestVariant($i, 'landing_page_cta_display_variant_begin_setup');
|
|
||||||
|
|
||||||
$i->click('Begin setup');
|
$i->click('Begin setup');
|
||||||
|
|
||||||
$i->waitForText('Start by configuring your sender information');
|
$i->waitForText('Start by configuring your sender information');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function abTestButtonWorks(\AcceptanceTester $i) {
|
|
||||||
$i->wantTo('Check landingpage AB test button works');
|
|
||||||
$i->login();
|
|
||||||
|
|
||||||
// show welcome wizard & landing page
|
|
||||||
$settings = new Settings();
|
|
||||||
$settings->withWelcomeWizard();
|
|
||||||
|
|
||||||
(new Features())->withFeatureEnabled(FeaturesController::LANDINGPAGE_AB_TEST_DEBUGGER);
|
|
||||||
|
|
||||||
$i->amOnMailpoetPage('Emails');
|
|
||||||
|
|
||||||
$this->selectAbTestVariant($i, 'landing_page_cta_display_variant_begin_setup');
|
|
||||||
|
|
||||||
$i->see('Begin setup');
|
|
||||||
|
|
||||||
$this->selectAbTestVariant($i, 'landing_page_cta_display_variant_get_started_for_free');
|
|
||||||
|
|
||||||
$i->see('Get started for free');
|
|
||||||
}
|
|
||||||
|
|
||||||
private function selectAbTestVariant(\AcceptanceTester $i, $testVariant) {
|
|
||||||
$i->canSeeElementInDOM('#pushtell-debugger');
|
|
||||||
$i->click('.pushtell-container.pushtell-handle'); // open debug panel
|
|
||||||
$i->see($testVariant);
|
|
||||||
$i->selectOption(".pushtell-experiment input[value=$testVariant]", $testVariant);
|
|
||||||
$i->click('.pushtell-close'); // close debug panel
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user