Skip to content

Instantly share code, notes, and snippets.

View ericakfranz's full-sized avatar

Erica Franz ericakfranz

View GitHub Profile
@ericakfranz
ericakfranz / OptinMonsterTracked.js
Created December 7, 2015 22:17
Write to the console when an OM optin is successfully tracked.
jQuery(document).ready( function($){
$(document).on('OptinMonsterTracked', function( event, data, object ){
console.log(data.optin + '-' + data.type + " successfully tracked");
});
});
@ericakfranz
ericakfranz / OptinMonsterOnClose.js
Created December 7, 2015 22:16
Stop a video from playing in our Canvas lightbox optin when it closes.
jQuery(document).ready( function($){
//Snag the URL of the iframe so we can use it later
var url = $('.optin_custom_html_applied iframe').attr('src');
$(document).on('OptinMonsterOnClose', function( event, data, object){
//Assign the iframe's src to null, which kills the video
$('.optin_custom_html_applied iframe').attr('src', '');
});
});
@ericakfranz
ericakfranz / OptinMonsterBeforeOptin.js
Last active May 19, 2016 19:18
Add a custom redirect url (http://optinmonster.com/) if the subscriber uses a non-business email address such as yahoo, gmail, hotmail, etc.
jQuery(document).ready(function($){
$(document).on('OptinMonsterBeforeOptin', function(event, data, object){
// Grab the email address submitted by the user.
var email = $('#om-' + data.optin).find('input[type="email"]').val();
// Test to ensure it is a proper email. Otherwise, redirect to another page.
if ( /@yahoo.com$/.test(email) || /@gmail.com$/.test(email) || /@hotmail.com$/.test(email) || /@googlemail.com$/.test(email) || /@live.com$/.test(email) || /@aol.com$/.test(email) || /@outlook.com$/.test(email) || /@comcast.net$/.test(email) || /@inbox.com$/.test(email) || /@hushmail.com$/.test(email) || /@lycos.com$/.test(email) || /@zoho.com$/.test(email) || /@gmx.com$/.test(email) ) {
window[data.optin_js].optin = function(){
return window.location.href = 'http://optinmonster.com/';
};
@ericakfranz
ericakfranz / OptinMonsterBeforeClose.js
Created December 7, 2015 22:14
Redirect to a specific url before the optin closes.
jQuery(document).ready( function($){
$(document).on('OptinMonsterBeforeClose', function( event, data, object ){
var url = "http://optinmonster.com";
$(location).attr('href',url);
});
});
@ericakfranz
ericakfranz / OptinMonsterPositionOptin.js
Created December 7, 2015 22:12
Make OM optin draggable using the Dragon jQuery script -- https://github.com/jeremyckahn/dragon
jQuery(document).ready( function($){
$(document).on('OptinMonsterPositionOptin', function( event, data, object ){
$('#om-canvas-whiteboard-optin').dragon();
});
});
@ericakfranz
ericakfranz / OptinMonsterOnShow.js
Created December 7, 2015 22:11
Stop a video from playing when the optin closes, then add the video url back when the optin opens - useful for Manual Trigger optins.
jQuery(document).ready( function($){
//Snag the URL of the iframe so we can use it later
var url = $('.optin_custom_html_applied iframe').attr('src');
$(document).on('OptinMonsterOnShow', function( event, data, object){
//Below we remove the URL to stop the video from playing, here we add it back in
$('.optin_custom_html_applied iframe').attr('src', url);
});
$(document).on('OptinMonsterOnClose', function( event, data, object){
@ericakfranz
ericakfranz / OptinMonsterBeforeShow.css
Last active December 7, 2015 22:09
Load a div containing a YouTube video set to autoplay behind our manually-triggered optin just before the optin shows. We’ll load the overlay only on desktop browsers and trigger the overlay to close with the ESC key.
/* --- CSS to position the video overlay --- */
#overlay {
position: fixed;
left: 0;
top: -90px;
bottom: 0;
right: 0;
width: 100%;
height: 500%;
background: #000;
@ericakfranz
ericakfranz / OptinMonsterLoaded.js
Created December 7, 2015 22:02
Write to the console when an OM optin has successfully loaded into the DOM.
jQuery(document).ready( function($){
$(document).on('OptinMonsterLoaded', function( event, data, object ){
console.log("Congratulations! The " + data.optin + '-' + data.type + " optin has been successfully loaded.");
});
});
@ericakfranz
ericakfranz / OptinMonsterManualOptinError.js
Created December 7, 2015 22:01
Write to the console when a manually-triggered OM optin fails to load into the DOM as expected.
jQuery(document).ready( function($){
$(document).on('OptinMonsterManualOptinError', function( event, data, object ){
console.log("Oops! There was a problem loading the " + data.optin + '-' + data.type + " manual-trigger optin on this page.");
});
});
@ericakfranz
ericakfranz / OptinMonsterManualOptinSuccess.js
Created December 7, 2015 22:00
Write to the console a message whenever a manually-triggered OM optin is loaded into the DOM.
jQuery(document).ready( function($){
$(document).on('OptinMonsterManualOptinSuccess', function( event, data, object ){
console.log("Congratulations! The " + data.optin + '-' + data.type + " manual-trigger optin has been successfully loaded.");
});
});