Business intelligence & user acquisition insight delivered to your inbox:


Posts Tagged With ‘javascript’


Optimizely Custom Event: Successful Email Submission

When I’m working on a user acquisition project, I use Optmizely to A/B test the email capture landing page.  I always create a custom event that triggers when the user successfully submits an email. Unfortunately, Optmizely doesn’t have a proper API which makes doing this difficult without redirecting to a new page.

It took me awhile to figure out a workaround in Javascript so I wanted to save everyone else the trouble:

First create a regex function to validate an email

function validateEmail(email) {
     var valid_email = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
     return valid_email.test(email);
}

Next, create a function that fires when the user clicks the submit button

 $( document ).ready(function() {
     $("input[type=submit]").bind("mousedown", function validate () {
     }):
}):

Put the entered email into a variable

var email = $("input[type=text]").val();

Write an if statement that uses our ValidEmail function to test if the email is valid

if (validateEmail(email)) {

If the email is valid, send the event to Optimizely

if (validateEmail(email)) {
     window['optimizely'] = window['optimizely'] || [];
     window.optimizely.push(['trackEvent', 'email_submit'])

In the last line we are calling our event ‘email_submit’. You can change this to any event name that you want.

All together it looks like this:

function validateEmail(email) {
     var valid_email = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
     return valid_email.test(email);
}

$( document ).ready(function() {
     $("input[type=submit]").bind("mousedown", function validate () {
     var email = $("input[type=text]").val();
          if (validateEmail(email)) {
               window['optimizely'] = window['optimizely'] || [];
               window.optimizely.push(['trackEvent', 'email_submit'])
          }
     });
});

In Optimizely create a new custom event goal. Set “Custom Event to track” to email_submit.

optimizely custom event


How To Start a Daily Deals Site (Part 1)

The success of LivingSocial and GroupOn has garnered a lot of interest in their business model.  Almost every content site is evaluating whether they should add a daily deals component to their business.  This is a guide to decide whether or not you should start a daily deals business, and if so how to go about doing it.    I take a very metrics driven approach.  If you are evaluating this from a marketing and strategy perspective, I would refer to Yipit’s guide here.

As a metrics consultant, I have helped a number of companies in the daily deals space through this process. As a word of warning, this is EXTREMELY hard.  The simplicity of the user-facing software makes this business look deceptively easy.  All of the complexity is hidden behind the scenes.  That said, here we go.

Part 1: Should I Start a Daily Deals Business?


Murad Reviews
Exposed Skin Care Reviews
Proactive Reviews
How To Get Rid Of Acne
How To Get Rid Of Stretch Marks
How To Get Rid Of Blackheads
how do i get rid of stretch marks
How To Make Stretch Marks Go Away
How To Get Rid Of Stretch Marks On Breasts
Stretch Marks After Pregnancy
How To Prevent Stretch Marks During Pregnancy
How to Get Rid of Stretch Marks