Skip to content

Instantly share code, notes, and snippets.

View ericakfranz's full-sized avatar

Erica Franz ericakfranz

View GitHub Profile
@ericakfranz
ericakfranz / autofill-om-optin-email-field.js
Created March 11, 2022 19:26
Autofill the optin email field and hide it. Specifically for use with gamified (spinning wheel) campaigns to allow spinning the wheel without collecting an email.
document.addEventListener('om.Campaign.afterShow', function(event) {
// Replace YOUR_DUMMY_EMAIL with the email address you want to autofill the field with.
// A validly formatted email address is required here.
var emailValue = "YOUR_DUMMY_EMAIL";
document.getElementById("{{ns}}-field-email").value = emailValue;
});
// Set OptinMonster Global Cookies when this function runs
function setGlobalCookies() {
document.cookie = "omSuccessCookie=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
document.cookie = "omGlobalSuccessCookie=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
document.cookie = "omGlobalInteractionCookie=true; expires=Fri, 31 Dec 9999 23:59:59 GMT";
}
@ericakfranz
ericakfranz / query-separator-smart-tag.js
Created February 26, 2022 16:16
Check if the URL already contains a query argument and choose whether to output a '?' or '&' character before any other string.
function mySep() {
var url = window.location.href;
if (url.indexOf('?') != -1) {
var sep = '&';
} else var sep = '?';
console.log(sep);
return sep;
}
html div#om-{{id}} {
left: 0 !important;
height: 540px !important;
top: calc(540px / 2) !important;
bottom: calc(540px / 2) !important;
margin-top: auto !important;
margin-bottom: auto !important;
animation: 1s ease-out 0s 1 slideInFromLeft;
}
@keyframes slideInFromLeft {
html div#om-{{id}} {
margin-right: -20px !important;
height: 540px !important;
top: calc(540px / 2) !important;
bottom: calc(540px / 2) !important;
margin-top: auto !important;
margin-bottom: auto !important;
animation: 1s ease-out 0s 1 slideInFromRight;
}
@keyframes slideInFromRight {
@ericakfranz
ericakfranz / setUTMCookie.js
Created February 23, 2022 20:45
Set a cookie if the URL contains specific UTM parameters.
function setUTMCookie() {
// Search the URL
var url = window.location.search;
// Store the UTMs we're searching for in a variable
var emailCampaignUTMs = '?utm_source=digg&utm_medium=email&utm_campaign=free_plus_shipping&utm_content=hhc_bundle';
// Calculate the expiration date for our cookie (1 year from the date it's set)
var cookieDate = new Date;
html div#om-{{id}} {
right: auto !important;
margin-left: 20px !important;
}
html div#om-{{id}} {
width: 350px !important;
left: calc(350px / 2) !important;
right: calc(350px / 2) !important;
margin-left: auto !important;
margin-right: auto !important;
}
html div#om-{{id}} {
top: 0px !important;
bottom: unset !important;
width: 350px !important;
left: calc(350px / 2) !important;
right: calc(350px / 2) !important;
margin-left: auto !important;
margin-right: auto !important;
transition: top 0.3s ease 0s !important;
}
html div#om-{{id}} {
top: 0px !important;
bottom: unset !important;
right: auto !important;
margin-left: 20px !important;
transition: top 0.3s ease 0s !important;
}