Skip to content

Instantly share code, notes, and snippets.

View ericakfranz's full-sized avatar

Erica Franz ericakfranz

View GitHub Profile
@ericakfranz
ericakfranz / OptinMonsterCustomDone.js
Created December 7, 2015 22:32
Write to the console when the custom OM optin has finished loading.
jQuery(document).ready(function($){
$(document).on('OptinMonsterCustomDone', function(event, data, object){
console.log(data.optin + '-' data.type + ' is using a custom optin form and has finished loading.');
});
});
@ericakfranz
ericakfranz / OptinMonsterAppendHolder.js
Created December 7, 2015 22:30
Write to the console when the main OM optin container has been attached to the outer DOM.
jQuery(document).ready(function($){
$(document).on('OptinMonsterAppendHolder', function(event, data, object){
console.log('The ' + data.optin + '-' + data.type + ' main container is now attached to the outer DOM.');
});
});
@ericakfranz
ericakfranz / OptinMonsterOptinError.js
Created December 7, 2015 22:29
Redirect to a specific url if there's an error.
jQuery(document).ready(function($){
$(document).on('OptinMonsterOnError', function(event, data, object){
var url = "http://optinmonster.com";
$(location).attr('href',url);
});
});
@ericakfranz
ericakfranz / OptinMonsterOptinSuccessClose.js
Last active December 7, 2015 22:28
Trigger file download once a successfully submitted optin is closed.
// Function SaveToDisk forces file download instead of viewing in browser
function SaveToDisk(fileURL, fileName) {
// for non-IE
if (!window.ActiveXObject) {
var save = document.createElement('a');
save.href = fileURL;
save.target = '_blank';
save.download = fileName || 'unknown';
var event = document.createEvent('Event');
@ericakfranz
ericakfranz / OptinMonsterOnRedirect.js
Created December 7, 2015 22:23
Write to the console when an OM optin is about to redirect to the specified Redirect URL (native integrations only).
jQuery(document).ready( function($){
$(document).on('OptinMonsterOnRedirect', function(event, data, object){
console.log(“Redirect in progress..”);
});
});
@ericakfranz
ericakfranz / OptinMonsterOptinSuccess.js
Created December 7, 2015 22:22
Close the OM optin after a successful submission.
jQuery(document).ready( function($){
$(document).on('OptinMonsterOptinSuccess', function( event, data, object ){
object.close();
});
});
@ericakfranz
ericakfranz / OptinMonsterOnError.js
Created December 7, 2015 22:21
Animate the error messages displayed each time they're triggered.
jQuery(document).ready( function($){
$(document).on('OptinMonsterOnError', function(event, data, object){
var l = 20;
for( var i = 0; i < 10; i++ )
$( ".optin-monster-error" ).animate( { 'margin-left': "+=" + ( l = -l ) + 'px' }, 50);
});
});
@ericakfranz
ericakfranz / OptinMonsterTrackedConversion.js
Created December 7, 2015 22:20
When an OM optin tracks a Conversion, push an event to GA account.
jQuery(document).ready( function($) {
$(document).on('OptinMonsterTrackedConversion', function( event, data, object ){
dataLayer.push({
'event': 'gaTriggerEvent',
'gaEventCategory': 'form',
'gaEventAction': 'submit',
'gaEventLabel': 'optin-monster'
});
});
});
@ericakfranz
ericakfranz / OptinMonsterPreOptin.js
Created December 7, 2015 22:19
Write to the console when an OM optin is about to be successfully converted.
jQuery(document).ready( function($){
$(document).on('OptinMonsterTrackedImpression', function( event, data, object ){
console.log('A successful conversion is about to be made for the ' + data.optin + '-' + data.type + ' optin.');
});
});
@ericakfranz
ericakfranz / OptinMonsterTrackedImpression.js
Created December 7, 2015 22:18
Write to the console when an OM optin successfully tracks an Impression.
jQuery(document).ready( function($){
$(document).on('OptinMonsterTrackedImpression', function( event, data, object ){
console.log(data.optin + '-' + data.type + ' successfully tracked an impression.');
});
});