mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
track distinct email submit forms
This commit is contained in:
parent
31e77d25b1
commit
89d9940ba4
5 changed files with 60 additions and 30 deletions
|
@ -8,7 +8,10 @@
|
|||
class Session
|
||||
{
|
||||
const KEY_MAILCHIMP_LIST_IDS = 'mailchimp_list_ids',
|
||||
KEY_LIST_SUB_SUCCESS = 'list_success';
|
||||
KEY_LIST_SUB_ERROR = 'list_error',
|
||||
KEY_LIST_SUB_SIGNATURE = 'list_sub_sig',
|
||||
KEY_LIST_SUB_SUCCESS = 'list_success',
|
||||
KEY_LIST_SUB_FB_EVENT = 'list_sub_fb_event';
|
||||
|
||||
public static function init()
|
||||
{
|
||||
|
|
|
@ -17,6 +17,10 @@ class ContentActions extends Actions
|
|||
|
||||
public static function executeGet()
|
||||
{
|
||||
if (isset($_GET['email']) && $_GET['email'] && Session::get(Session::KEY_LIST_SUB_ERROR))
|
||||
{
|
||||
Controller::redirect('/get');
|
||||
}
|
||||
return ['page/get', [
|
||||
'isSubscribed' => $_GET['email'] || in_array(Mailchimp::LIST_GENERAL_ID, Session::get(Session::KEY_MAILCHIMP_LIST_IDS, []))
|
||||
]];
|
||||
|
|
|
@ -15,6 +15,8 @@ class MailActions extends Actions
|
|||
{
|
||||
Controller::redirect($nextUrl);
|
||||
}
|
||||
|
||||
Session::set(Session::KEY_LIST_SUB_SIGNATURE, isset($_POST['listSig']) ? $_POST['listSig'] : true);
|
||||
|
||||
$email = $_POST['email'];
|
||||
if (!$email|| !filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
|
@ -34,7 +36,8 @@ class MailActions extends Actions
|
|||
if ($success)
|
||||
{
|
||||
Session::set(Session::KEY_MAILCHIMP_LIST_IDS, array_merge(Session::get(Session::KEY_MAILCHIMP_LIST_IDS, []), [$mcListId]));
|
||||
Session::set(Session::KEY_LIST_SUB_SUCCESS, __('Great success! Welcome to LBRY.'));
|
||||
Session::set(Session::KEY_LIST_SUB_SUCCESS, true);
|
||||
Session::set(Session::KEY_LIST_SUB_FB_EVENT, isset($_POST['fbEvent']) ? $_POST['fbEvent'] : null);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -48,11 +51,24 @@ class MailActions extends Actions
|
|||
|
||||
public static function prepareJoinList(array $vars)
|
||||
{
|
||||
$vars['listSig'] = md5(serialize($vars));
|
||||
$vars += ['btnClass' => 'btn-primary', 'returnUrl' => $_SERVER['REQUEST_URI']];
|
||||
$vars['error'] = Session::get('list_error');
|
||||
$vars['success'] = Session::get(Session::KEY_LIST_SUB_SUCCESS);
|
||||
Session::unsetKey('list_error');
|
||||
Session::unsetKey(Session::KEY_LIST_SUB_SUCCESS);
|
||||
|
||||
if (Session::get(Session::KEY_LIST_SUB_SIGNATURE) == $vars['listSig'])
|
||||
{
|
||||
$vars['error'] = Session::get('list_error');
|
||||
Session::unsetKey('list_error');
|
||||
|
||||
$vars['success'] = Session::get(Session::KEY_LIST_SUB_SUCCESS) ? __('Great success! Welcome to LBRY.') : false;
|
||||
$vars['fbEvent'] = Session::get(Session::KEY_LIST_SUB_FB_EVENT) ?: 'Lead';
|
||||
Session::unsetKey(Session::KEY_LIST_SUB_SUCCESS);
|
||||
Session::unsetKey(Session::KEY_LIST_SUB_FB_EVENT);
|
||||
}
|
||||
else
|
||||
{
|
||||
$vars['success'] = false;
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,23 +5,29 @@
|
|||
<?php js_start() ?>
|
||||
ga('send', 'event', 'Sign Up', 'Join List', '<?php echo $listId ?>');
|
||||
twttr.conversion.trackPid('nty1x');
|
||||
fbq('track', "Lead");
|
||||
fbq('track', <?php echo $fbEvent ?>);
|
||||
<?php js_end() ?>
|
||||
<div class="notice notice-success spacer1"><?php echo $success ?></div>
|
||||
<?php endif ?>
|
||||
<div class="mail-submit">
|
||||
<input type="hidden" name="returnUrl" value="<?php echo $returnUrl ?>"/>
|
||||
<input type="hidden" name="listId" value="<?php echo $listId ?>"/>
|
||||
<input type="email" value="" name="email" class="required email standard" placeholder="someone@somewhere.com">
|
||||
<input type="submit" value="<?php echo isset($submitLabel) ? $submitLabel : 'Subscribe' ?>" name="subscribe" id="mc-embedded-subscribe" class="<?php echo $btnClass ?>">
|
||||
<?php if (isset($mergeFields)): ?>
|
||||
<input type="hidden" name="mergeFields" value="<?php echo htmlentities(serialize($mergeFields)) ?>" />
|
||||
<?php endif ?>
|
||||
<?php if (isset($meta) && $meta): ?>
|
||||
<div class="meta">
|
||||
<?php echo __('You will receive 1-2 messages a month, only from LBRY, Inc. and only about LBRY.') ?>
|
||||
<?php echo __('You can easily unsubscribe at any time.') ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php if ($error || !$success): ?>
|
||||
<div class="mail-submit">
|
||||
<input type="hidden" name="returnUrl" value="<?php echo $returnUrl ?>"/>
|
||||
<input type="hidden" name="listId" value="<?php echo $listId ?>"/>
|
||||
<input type="hidden" name="listSig" value="<?php echo $listSig ?>"/>
|
||||
<input type="email" value="" name="email" class="required email standard" placeholder="someone@somewhere.com">
|
||||
<input type="submit" value="<?php echo isset($submitLabel) ? $submitLabel : 'Subscribe' ?>" name="subscribe" id="mc-embedded-subscribe" class="<?php echo $btnClass ?>">
|
||||
<?php if (isset($fbEvent)): ?>
|
||||
<input type="hidden" name="fbEvent" value="<?php echo $fbEvent ?>" />
|
||||
<?php endif ?>
|
||||
<?php if (isset($mergeFields)): ?>
|
||||
<input type="hidden" name="mergeFields" value="<?php echo htmlentities(serialize($mergeFields)) ?>" />
|
||||
<?php endif ?>
|
||||
<?php if (isset($meta) && $meta): ?>
|
||||
<div class="meta">
|
||||
<?php echo __('You will receive 1-2 messages a month, only from LBRY, Inc. and only about LBRY.') ?>
|
||||
<?php echo __('You can easily unsubscribe at any time.') ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</form>
|
|
@ -28,15 +28,16 @@
|
|||
</div>
|
||||
<h1><?php echo __('I am a Linux or OS X user comfortable from the command line.') ?></h1>
|
||||
<p class="pflow">Earn early adopter rewards and interact directly with developers via our Alpha client.</p>
|
||||
<div class="spacer1">
|
||||
<?php echo View::render('mail/joinList', [
|
||||
'submitLabel' => 'Go',
|
||||
'listId' => Mailchimp::LIST_GENERAL_ID,
|
||||
'mergeFields' => ['CLI' => 'Yes'],
|
||||
'fbEvent' => 'Alpha',
|
||||
'returnUrl' => '/get?email=1'
|
||||
]) ?>
|
||||
</div>
|
||||
<?php if (!$isSubscribed): ?>
|
||||
<div class="spacer1">
|
||||
<?php echo View::render('mail/joinList', [
|
||||
'submitLabel' => 'Go',
|
||||
'listId' => Mailchimp::LIST_GENERAL_ID,
|
||||
'mergeFields' => ['CLI' => 'Yes'],
|
||||
'returnUrl' => '/get?email=1'
|
||||
]) ?>
|
||||
</div>
|
||||
<div class="meta">
|
||||
Already signed up or really hate sharing your email? <a href="/get?email=1" class="link-primary">Click here.</a>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue