Skip to content

Instantly share code, notes, and snippets.

@nfriend21
Created September 8, 2022 11:47
Show Gist options
  • Save nfriend21/2be2885efe8b3b8b8d09e1dd41fa43d4 to your computer and use it in GitHub Desktop.
Save nfriend21/2be2885efe8b3b8b8d09e1dd41fa43d4 to your computer and use it in GitHub Desktop.
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W75DFV');</script>
<!-- End Google Tag Manager -->
<!-- Recaptcha V3 -->
<script src="https://www.google.com/recaptcha/api.js?render=6LdUPEsaAAAAAKA8ItbzI31D9rcP0PlGOmQEfFgO"></script>
<style>.grecaptcha-badge { visibility: hidden; }</style>
<!-- End of Recaptcha V3 -->
<meta name="referrer" content="always">
<script>
function getURLParameters(url) {
var result = {};
var searchIndex = url.indexOf("?");
if (searchIndex == -1 ) return result;
var sPageURL = url.substring(searchIndex +1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
result[sParameterName[0]] = sParameterName[1];
}
return result;
}
function preventMultipleFormSubmissionsOnClick() {
jQuery('[data-prevent-multiple-form-submissions="true"]').each(function() {
var button = jQuery(this);
button.closest('form').submit(function() {
console.log('stopped')
jQuery(this).find("button[type='submit']").prop('disabled',true);
jQuery(this).find("input[type='submit']").prop('disabled',true);
})
})
}
function setURLPathForInquirySourceValue() {
jQuery('[name="inquiry[dynamic_fields][inquiry_location]"').val(window.location.pathname)
}
function setHiddenFieldsOnDemoRequestForm() {
var trigger = jQuery('[data-set-value-via-js]').first();
if ( trigger.length) {
var identifiers = trigger.data('set-value-via-js').split(',');
console.log(identifiers)
jQuery.each(identifiers, function(index, val) {
var identifier = val.split('|')[0],
value = val.split('|')[1],
target = jQuery( '[data-set-value-via-js-identifier="' + identifier + '"');
if ( target.length ) {
target.val(value);
}
});
}
}
function updateLeadonASF() {
console.log('===within updateLeadonASF()')
var urlParams = getURLParameters(window.location.href);
// only update if CRM cookie is set. Otherwise, keep collecting data in the various cookies.
// need to change this to update lead on any visit based on ip, and send the page URL each time, so it can be appended into the lead record.
if ( ( Cookies.get('AsfCrmLeadID') !== undefined && Cookies.get('AsfCrmLeadID') != '0' ) || urlParams['crm_lead_id'] !== undefined ) {
var crm_lead_id = ( urlParams['crm_lead_id'] !== undefined ) ? urlParams['crm_lead_id'] : Cookies.get('AsfCrmLeadID'),
url = "https://www.artstorefronts.com/resellers/artstorefronts/leads/visitor_data?crm_lead_id=" + crm_lead_id + "&callback=?";
// this is necessary in order to bypass CORS.
urlParams['callback'] = '?'
jQuery.getJSON( url, urlParams, function(result) {
// this call sets the cookies from within the ASF app just by sending the call.
});
}
}
// function replaceBookAnAppointmentLink() {
// if ( Cookies.get('AsfHasExistingWebsite') == 'true' ) {
// var link = jQuery('[data-book-an-appointment="true"]');
// if ( link.length ) {
// link.attr('href', 'https://secure.scheduleonce.com/schedule-introductory-call')
// }
// }
// }
function createAffiliateCookie() {
var params = getURLParameters(window.location.href),
affiliateParamExists = params['partner_id'] !== undefined,
noCookie = ( Cookies.get('AsfAffiliateID') === undefined || Cookies.get('AsfAffiliateID') == 'undefined' );
if ( noCookie && affiliateParamExists ) {
Cookies.set("AsfAffiliateID", params['partner_id'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForLastVisitDate() {
var date = new Date();
Cookies.set("AsfLastVisitDate", date.toLocaleString(), {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
function createCookieForFirstVisitDate() {
var date = new Date(),
noCookie = ( Cookies.get('AsfFirstVisitDate') === undefined || Cookies.get('AsfFirstVisitDate') == 'undefined' );
if ( noCookie ) {
Cookies.set("AsfFirstVisitDate", date.toLocaleString(), {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForCRMLead() {
var params = getURLParameters(window.location.href),
noCookie = ( Cookies.get('AsfCrmLeadID') === undefined || Cookies.get('AsfCrmLeadID') == 'undefined' ),
CRMParam = params['crm_lead_id'] !== undefined,
wrongCRMParam = ['{!Lead.Id}', 'undefined', "*|CRMLEADID|*", "%7B!Lead.Id%7D", "%20Test%20CRMLEADID"].includes(params['crm_lead_id']);
if ( noCookie && CRMParam || wrongCRMParam && CRMParam ) {
// console.log('setting CRM lead')
// console.log(noCookie)
// console.log(noCRMParam)
// console.log(wrongCRMParam)
Cookies.set("AsfCrmLeadID", params['crm_lead_id'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function canSetMarketingSource(utm_source) {
['popular_posts', 'popular%20posts', 'sidebar', 'home_art', 'blog-interlinking', 'blog-post', undefined].indexOf(utm_source) < 0
}
function createCookiesForFirstMarketingSource() {
console.log(Cookies.get('newVisitor'))
var params = getURLParameters(window.location.href);
if ( params['utm_source'] !== undefined && Cookies.get('AsfFirstMarketingSource') === undefined && Cookies.get('AsfFirstMarketingTerm') === undefined && Cookies.get('AsfFirstMarketingAdContent') === undefined && Cookies.get('newVisitor') === undefined ) {
Cookies.set("AsfFirstMarketingSource", params['utm_source'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfFirstMarketingAdContent", params['utm_content'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfFirstMarketingMedium", params['utm_medium'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfFirstMarketingTerm", params['utm_term'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfFirstMarketingCampaign", params['utm_campaign'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfOriginatingAudience", params['originating_audience'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookiesForLastMarketingSource() {
var params = getURLParameters(window.location.href);
if ( params['utm_source'] !== undefined ) {
Cookies.set("AsfLastMarketingSource", params['utm_source'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfLastMarketingAdContent", params['utm_content'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfLastMarketingMedium", params['utm_medium'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfLastMarketingTerm", params['utm_term'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
Cookies.set("AsfLastMarketingCampaign", params['utm_campaign'], {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
if ( /facebook/.test(params['utm_source']) && /cold|warm/.test(params['utm_medium']) ) {
var date = new Date();
Cookies.set("AsfLastFacebookAdDate", date.toLocaleString(), {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForNewVisitor() {
if ( Cookies.get('newVisitor') === undefined ) {
var params = getURLParameters(window.location.href);
Cookies.set("newVisitor", params, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createUpdateHistoricalVisitCountCookie() {
if ( Cookies.get('AsfHistoricalVisitCount') === undefined ) {
Cookies.set("AsfHistoricalVisitCount", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
else {
var oldVisitCount = parseInt( Cookies.get('AsfHistoricalVisitCount') ) || 0;
Cookies.set("AsfHistoricalVisitCount", (oldVisitCount + 1), {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createUpdateBlogVisitCountCookie() {
if ( location.hostname.match(/blog/) && Cookies.get('AsfIsCustomer') > 0 ) {
if ( Cookies.get('AsfBlogVisitCountSinceCustomer') === undefined ) {
Cookies.set("AsfBlogVisitCountSinceCustomer", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
else {
var oldVisitCount = parseInt( Cookies.get('AsfBlogVisitCountSinceCustomer') ) || 0;
Cookies.set("AsfBlogVisitCountSinceCustomer", (oldVisitCount + 1), {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
}
function createUpdateBlogLastVisitedAtCookie() {
if ( location.hostname.match(/blog/) && Cookies.get('AsfIsCustomer') > 0 ) {
Cookies.set("AsfBlogLastVisitedAtSinceCustomer", jQuery.now(), {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createUpdateLastURLVisitsCookie() {
var urlPathExclusions = [
'/visitor_data',
],
currentPath = window.location.pathname,
urlPathValidates = jQuery.inArray(currentPath, urlPathExclusions) == -1;
if ( urlPathValidates ) {
if ( Cookies.get('AsfLastUrlVisits') === undefined ) {
var params = {},
date = new Date();
params[ date.toLocaleString() ] = 'blog:' + (location.pathname+location.search).substr(1);
Cookies.set("AsfLastUrlVisits", params, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
else {
var currentParams = Cookies.getJSON('AsfLastUrlVisits'),
currentFootprintCount = Object.keys(currentParams).length,
date = new Date();
if ( currentFootprintCount <= 5 ) {
currentParams[ date.toLocaleString() ] = 'blog:' + (location.pathname+location.search).substr(1);
Cookies.set("AsfLastUrlVisits", currentParams, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
else {
delete currentParams[Object.keys(currentParams)[0]]
currentParams[ date.toLocaleString() ] = 'blog:' + (location.pathname+location.search).substr(1);
Cookies.set("AsfLastUrlVisits", currentParams, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
}
}
function createUpdateFootprintCookie() {
var urlPathExclusions = [
'/visitor_data',
],
currentPath = window.location.pathname,
urlPathValidates = jQuery.inArray(currentPath, urlPathExclusions) == -1;
if ( urlPathValidates ) {
if ( Cookies.get('userFootprint') === undefined ) {
var params = {},
date = new Date();
params[ date.toLocaleString() ] = 'blog:' + (location.pathname+location.search).substr(1);
Cookies.set("userFootprint", params, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
else {
var currentParams = Cookies.getJSON('userFootprint'),
currentFootprintCount = Object.keys(currentParams).length,
date = new Date();
if ( currentFootprintCount < 7 ) {
currentParams[ date.toLocaleString() ] = 'blog:' + (location.pathname+location.search).substr(1);
Cookies.set("userFootprint", currentParams, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
}
}
function createUpdateReferralSiteCookie() {
var legitReferrer = (document.referrer && !document.referrer.match(/artstorefronts.com/) );
if ( Cookies.get('referralSites') === undefined ) {
var params = {},
date = new Date();
params[ date.toLocaleString() ] = document.referrer;
if ( document.referrer.match(/artstorefronts.com/) ) {
// do nothing. not a referral. coming from main site, blog, or forum.
}
else if ( legitReferrer ) {
Cookies.set("referralSites", params, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
else {
var currentParams = Cookies.getJSON('referralSites'),
currentFootprintCount = Object.keys(currentParams).length,
date = new Date();
if ( currentFootprintCount < 7 && legitReferrer ) {
currentParams[ date.toLocaleString() ] = document.referrer;
Cookies.set("referralSites", currentParams, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
}
function setBehaviorCookies() {
createCookieForAboutPageVisit();
createCookieForCBTPageVisit();
createCookieForPricingPageVisit();
createCookieForTestimonialsPageVisit();
createCookieForMissionPageVisit();
createCookieForTheJourneyPostVisit();
createCookieForTwentyConvertingPostVisit();
createCookieForTheStoryPostVisit();
createCookieForPodcastPageVisit();
createCookieForStartOnlineArtGalleryPageVisit();
createCookieForRunningArtGalleryBusinessOnlinePageVisit();
}
function createCookieForRunningArtGalleryBusinessOnlinePageVisit() {
if ( window.location.pathname == "/running-art-gallery-business-online/" ) {
Cookies.set("AsfAnyPageRunningArtGalleryBusinessOnlineVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForStartOnlineArtGalleryPageVisit() {
if ( window.location.pathname == "/start-online-art-gallery/" ) {
Cookies.set("AsfAnyPageStartOnlineArtGalleryVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForAboutPageVisit() {
if ( window.location.pathname == "/about/" ) {
Cookies.set("AsfAnyPageAboutVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForCBTPageVisit() {
if ( window.location.pathname == "/tour/" || window.location.pathname == '/' ) {
Cookies.set("AsfMainPageCBTVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForPricingPageVisit() {
if ( window.location.pathname == "/pricing/" ) {
Cookies.set("AsfMainPagePricingVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForTestimonialsPageVisit() {
if ( window.location.pathname == "/art-storefronts-reviews/" ) {
Cookies.set("AsfBlogPageTestimonialsVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForMissionPageVisit() {
if ( window.location.pathname == "/our-mission-starving-artist-problem/" ) {
Cookies.set("AsfBlogPageMissionVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForTheJourneyPostVisit() {
if ( window.location.pathname == "/how-to-sell-art-online/" ) {
Cookies.set("AsfBlogPageTheJourneyVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForTwentyConvertingPostVisit() {
if ( window.location.pathname == "/features-sell-art-online/" ) {
Cookies.set("AsfBlogPageTwentyConvertingVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForTheStoryPostVisit() {
if ( jQuery.inArray(window.location.pathname, ['/selling-art-story/', '/selling-art/']) !== -1 ) {
Cookies.set("AsfBlogPageTheStoryVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function createCookieForPodcastPageVisit() {
if ( jQuery.inArray(window.location.pathname, ['/podcast/']) !== -1 ) {
Cookies.set("AsfPodcastPageVisit", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function addURLParamsToAllLinks() {
var params = jQuery.param( Cookies.getJSON('newVisitor') )
jQuery('a[href]').each(function() {
jQuery(this).attr('href', ( jQuery(this).attr('href') + '?' + params) )
});
}
function addCookieParamsToForm(cookieName, formClass, formInputName) {
var inputValue = Cookies.get(cookieName),
hiddenInput = jQuery("<input>")
.attr("type", "hidden")
.attr("name", formInputName).val(inputValue);
jQuery(formClass).submit(function(e) {
jQuery(this).prepend(hiddenInput)
return true;
});
}
function addHiddenFieldToForm(formClass, formInputName, formInputValue) {
var hiddenInput = jQuery("<input>")
.attr("type", "hidden")
.attr("name", formInputName).val(formInputValue);
jQuery(formClass).submit(function(e) {
jQuery(this).prepend(hiddenInput)
return true;
});
}
function displayFlashMessageFromParams() {
var params = getURLParameters(window.location.href);
if ( params === undefined ) {
}
else {
var flashType = params['flash_type'],
flashMessage = params['flash_message'],
newFlashMessage;
if ( flashMessage ) {
newFlashMessage = flashMessage.split('+').join(' ');
newFlashMessage = newFlashMessage.replace(/%20/g, ' ')
newFlashMessage = newFlashMessage.replace(/%21/g, '!')
jQuery('#asf_flash_container').remove()
jQuery('body').prepend('<div id="asf_flash_container" class="flash-message ' + flashType + '">' + newFlashMessage + '</div>');
setTimeout(function() {
jQuery('#asf_flash_container').fadeOut()
}, 4000);
}
}
}
function LoadDriftVisitorTracker(drift) {
var data = visitorData(),
drift = drift || [];
getVisitorDataViaAjax();
console.log(data)
console.log(drift)
if ( jQuery.isEmptyObject( data ) || jQuery.isEmptyObject( drift ) ) {
console.log('NOT tracking in Drift')
}
else if ( data.AsfIsCustomer ) {
// this removes tracking from this user.
console.log('reset tracking in Drift')
drift.reset();
}
else {
console.log('tracking in Drift - A')
if ( !data.AsfIsCustomer && data.AsfHistoricalVisitCount >= 20 ) {
console.log('tracking in Drift - B')
drift.identify(data.AsfCrmLeadID,{
email: data.eOne,
historical_visit_count: data.AsfHistoricalVisitCount,
is_customer: data.AsfIsCustomer,
requested_demo: data.AsfRequestedDemo
});
}
}
}
function visitorData() {
var data = {};
if ( Cookies.get('AsfE') !== undefined ) {
var eOne = Cookies.get('AsfE'),
AsfCrmLeadID = Cookies.get('AsfCrmLeadID'),
AsfHistoricalVisitCount = Cookies.get('AsfHistoricalVisitCount'),
AsfIsCustomer = Cookies.get('AsfIsCustomer') > 0,
AsfRequestedDemo = Cookies.get('AsfRequestedDemo') == '1';
data['eOne'] = eOne;
data['AsfCrmLeadID'] = AsfCrmLeadID
data['AsfHistoricalVisitCount'] = AsfHistoricalVisitCount
data['AsfIsCustomer'] = AsfIsCustomer
data['AsfRequestedDemo'] = AsfRequestedDemo
}
return data
}
function getVisitorDataViaAjax() {
var AsfCrmLeadID = Cookies.get('AsfCrmLeadID'),
urlParams = getURLParameters(window.location.href),
url = "https://www.artstorefronts.com/resellers/artstorefronts/leads/visitor_data?crm_lead_id=" + AsfCrmLeadID + "&callback=?";
if ( Cookies.get('AsfCrmLeadID') !== undefined && Cookies.set("AsfRequestedDemo") !== '1' ) {
// this is necessary in order to bypass CORS.
urlParams['callback'] = '?'
jQuery.getJSON( url, urlParams, function(result) {
// setting cookie within ASF app.
});
}
}
function turnMainWebsiteNavLinkIntoTargetBlank() {
jQuery('#menu-item-4094 a').attr('target', 'blank')
}
function connectVisitorToDrip() {
// connect visitor when submitting form
jQuery('form').submit(function() {
var email = jQuery(this).find('[name="inquiry[email]"]').val()
console.log('email: ' + email)
if ( email !== undefined ) {
_dcq.push(["identify", {
email: email
}]);
}
})
// connect visitor based on cookie
if ( Cookies.get('AsfE') !== undefined ) {
_dcq.push(["identify", {
email: Cookies.get('AsfE')
}]);
}
}
function modifySubmitButtonsOnClick() {
jQuery('.new-inquiry').each(function() {
jQuery(this).submit(function() {
console.log('form submissions button will change text when clicked')
jQuery(this).find("button[type='submit']").attr('value', 'processing...')
jQuery(this).find("input[type='submit']").attr('value', 'processing...')
})
})
}
function fireFacebookConversionEvents() {
console.log('within fireFacebookConversionEvents()')
}
function setNoWelcomeMatCookie() {
var urlParams = getURLParameters(window.location.href),
urlStringExclusions = new RegExp(/utm_source=drip/),
urlHrefValidates = window.location.href.match(urlStringExclusions) != null;
if ( urlParams['no_w_mat'] == 'true' || urlHrefValidates ) {
Cookies.set("AsfNoWelcomeMat", 1, {
expires : 7200, // expires in n days
domain: 'artstorefronts.com'
});
}
}
function launchWelcomeMat(element, delay) {
var bypassOption = jQuery(element).data('bypass-option'),
urlParams = getURLParameters(window.location.href),
urlStringExclusions = new RegExp(/facebook_ads_stage_3|facebook_ads_stage_4|utm_source=drip|small-wins|art-storefronts-vs-squarespace|artist-demo-questions|artists-rock|demo-request-blog-failed-validation|demo-request-confirmed-website-yes|go|privacy-policy|podcast-subscription-confirmed|art-gallery001pre|artist-demo-prep-confirmed|asf-office-hours|cookie-policy|demo-request|demo-request-confirmed|demo-request-confirmed-website-no|demo-request-received|no-website|payment-failed|podcast-2|selling-art-story|artists-definetly-rock|test-thrive-switch\/photo|welcome-to-the-team|031-facebook-contests-q4-strategy|photo\/successful-art-storefronts-photographer-website-examples|7-website-features-sell-art-online|obtain-lifestyle-full-time-artist|budget_better_stable|023-megh-knappenberger-first-year/),
urlHrefValidates = window.location.href.match(urlStringExclusions) == null;
console.log('urlhref----' + urlHrefValidates)
if ( urlHrefValidates && Cookies.get('AsfNoWelcomeMat') === undefined && (Cookies.get('newVisitor') === undefined || urlParams['dev'] == 'true') ) {
setTimeout(function(){
jQuery(function () {
jQuery(element)
.css('opacity', 0)
.slideDown('slow')
.animate(
{ opacity: 1 },
{ queue: false,
duration: 'slow',
complete: function() {
jQuery('body').css('padding-top', jQuery(window).height() + 'px')
}
}
);
jQuery('body')
.animate(
{ 'padding-top': jQuery(window).height() + 'px' }
);
jQuery("html, body").animate({ scrollTop: 0 }, "fast");
});
jQuery(element + ' div.container').center();
jQuery('.asf-welcome-mat input#inquiry_email').focus();
}, delay);
jQuery(element + ' .refuse').on('click', function() {
jQuery(element).fadeOut();
jQuery('body').css('padding-top', '0px')
})
}
}
function fixPositionOfScrollingNavDueToHelloBar() {
if ( jQuery('.HB-Bar:visible').length > 0 ) {
jQuery('header.fbh').css('top', '45px')
}
}
window.onload = function() {
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", ( jQuery(window).height() - this.height() ) / 2 + "px");
this.css("left", ( jQuery(window).width() - this.width() ) / 2 + "px");
return this;
}
setNoWelcomeMatCookie();
launchWelcomeMat('.asf-welcome-mat', 0);
createCookiesForFirstMarketingSource();
createCookiesForLastMarketingSource();
createAffiliateCookie();
createUpdateHistoricalVisitCountCookie();
createCookieForFirstVisitDate();
createCookieForLastVisitDate();
createUpdateLastURLVisitsCookie();
createCookieForCRMLead();
createCookieForNewVisitor();
createUpdateFootprintCookie();
createUpdateReferralSiteCookie();
createUpdateBlogVisitCountCookie();
createUpdateBlogLastVisitedAtCookie();
modifySubmitButtonsOnClick();
setBehaviorCookies();
updateLeadonASF();
displayFlashMessageFromParams();
// addURLParamsToAllLinks();
addCookieParamsToForm('newVisitor', '.new-inquiry', 'inquiry[incoming_params]');
addCookieParamsToForm('userFootprint', '.new-inquiry', 'user_footprint');
addCookieParamsToForm('referralSites', '.new-inquiry', 'referral_sites');
//addHiddenFieldToForm('.new-inquiry', 'inquiry[dynamic_fields][source_url]', window.location.href);
setHiddenFieldsOnDemoRequestForm();
setURLPathForInquirySourceValue();
fixPositionOfScrollingNavDueToHelloBar();
//autoRedirectUponSubscriptionConfirmed();
turnMainWebsiteNavLinkIntoTargetBlank();
//replaceBookAnAppointmentLink();
preventMultipleFormSubmissionsOnClick();
fireFacebookConversionEvents();
connectVisitorToDrip();
//LoadDriftVisitorTracker(drift);
if ( Cookies.get('AsfIsCustomer') > 0 ) {
// hide manychat
console.log('is customer - manychat hidden')
setTimeout(function() {
jQuery('#fb-root').css('display', 'none')
}, 200)
}
}
</script>
<script>
/*!
* JavaScript Cookie v2.0.4
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
var _OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = _OldCookies;
return api;
};
}
}(function () {
function extend () {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[ i ];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}
function init (converter) {
function api (key, value, attributes) {
var result;
// Write
if (arguments.length > 1) {
attributes = extend({
path: '/'
}, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}
try {
result = JSON.stringify(value);
if (/^[{[]/.test(result)) {
value = result;
}
} catch (e) {}
if (!converter.write) {
value = encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
} else {
value = converter.write(value, key);
}
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[()]/g, escape);
return (document.cookie = [
key, '=', value,
attributes.expires && '; expires=' + attributes.expires.toUTCString(), // use expires attribute, max-age is not supported by IE
attributes.path && '; path=' + attributes.path,
attributes.domain && '; domain=' + attributes.domain,
attributes.secure ? '; secure' : ''
].join(''));
}
// Read
if (!key) {
result = {};
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
var i = 0;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var name = parts[0].replace(rdecode, decodeURIComponent);
var cookie = parts.slice(1).join('=');
if (cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}
try {
cookie = converter.read ?
converter.read(cookie, name) : converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);
if (this.json) {
try {
cookie = JSON.parse(cookie);
} catch (e) {}
}
if (key === name) {
result = cookie;
break;
}
if (!key) {
result[name] = cookie;
}
} catch (e) {}
}
return result;
}
api.get = api.set = api;
api.getJSON = function () {
return api.apply({
json: true
}, [].slice.call(arguments));
};
api.defaults = {};
api.remove = function (key, attributes) {
api(key, '', extend(attributes, {
expires: -1
}));
};
api.withConverter = init;
return api;
}
return init(function () {});
}));
</script>
<script src="https://use.typekit.net/uit6wsq.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
<script>
if ( window.location.pathname == "/geo-fencing-facebook/") {
}
else {
!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '620344144701385');
fbq('init', '1270568690003481');
fbq('track', "PageView");
console.log('=====FB PageView fired')
setTimeout(function() {
fbq('track', 'Lead');
console.log('=====FB Lead conversion fired')
}, 10000);
// drip code to track individual visitor by email address
if ( Cookies.get('AsfE') !== undefined ) {
setTimeout(function() {
_dcq.push(["identify", {
email: Cookies.get('AsfE'),
success: function(response) {
console.log('drip tracking response - ' + response.success)
}
}]);
}, 2000)
}
}
function redirectToAnotherPage() {
const pathname = window.location.pathname;
if (!pathname.includes('go/the-journey-make-most-money')) return;
const redirectToUrl = 'https://blog.artstorefronts.com/go/make-most-money-blanchard/';
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const isIncludeWord1 = urlParams.get('utm_term') && urlParams.get('utm_term').includes('blanchard');
const isIncludeWord2 = urlParams.get('utm_term') && urlParams.get('utm_term').includes('carousel');
if (isIncludeWord1 || isIncludeWord2) {
window.location.href = `${redirectToUrl}${queryString}`;
}
}
redirectToAnotherPage();
</script>
<!-- Start VWO Smartcode -->
<script src="https://dev.visualwebsiteoptimizer.com/lib/445606.js"></script>
<!-- End VWO Smartcode -->
<!-- ManyChat -->
<script src="//widget.manychat.com/607111749345832.js" async="async"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment