Chargement…
// Gets query parameters from url function n__getParameterByName(name, url) { if (!url) url = window.location.href; name = name.replace(/[[]]/g, "\$&"); var regex = new RegExp("[?&]" + name + "(=([^]*)|&"https://www.smilebrilliant.com/#"$)"), results = regex.exec(url); if (!results) return null; if (!results[2]) return ''; return decodeURIComponent(results[2].replace(/+/g, " ")); }
function n__handleProductAddToCart(n__productId, n__customization) { //fix customization string if(typeof n__customization == 'undefined' || n__customization == "") { n__customization = ""; }
//once the shopping cart changes, then do our events n__shoppingCart.n__onShoppingCartChange = function() { var n__itemRef = null; try { for(var i = 0; i < n__shoppingCart.n__itemArray['id'+n__productId].length; i++) { if(n__shoppingCart.n__itemArray['id'+n__productId][i].n__itemCustomization == n__customization) { n__itemRef = n__shoppingCart.n__itemArray['id'+n__productId][i]; } } }catch(err){} try { $zopim(function() { $zopim.livechat.addTags(n__itemRef.n__itemTitle.replace(/W+/g, "_")); }); }catch(err){} //event firing if(n__ipAddress != "68.251.254.114" && n__ipAddress != "47.47.12.154") { //fire buyer event try { n__buyerFootprintController.n__fireEvent("cart-add", n__itemRef.n__itemId, n__campaignSlug, "", false, true); }catch(err){} //google audience for people who add to cart try{ document.getElementById('adwordsCartAudienceImage').src = "https://googleads.g.doubleclick.net/pagead/viewthroughconversion/991526735/?value=0¤cy_code=USD&label=2ZpUCIPAvmsQz_7l2AM&guid=ON&script=0"; }catch(err){}; //google advanced ecommerce add to cart try{ ga('ec:addProduct', { 'id': n__itemRef.n__itemId, 'name': n__itemRef.n__itemTitle, 'category': n__itemRef.n__itemType, 'price': n__itemRef.n__itemPrice, 'quantity': 1 }); ga('ec:setAction', 'add'); ga('send', 'event', 'AddToCart'); }catch(err){}; //facebook add try{ fbq('track', 'AddToCart', { content_type: 'product', //product or product_group content_ids: [n__itemRef.n__itemId], //product id here content_name: n__itemRef.n__itemTitle }); }catch(err){}; //pinterest add try{ var n__pinterestAddToCartValues = new Array(); if(n__campaignSlug != "") { n__pinterestAddToCartValues['promo_code'] = n__campaignSlug; } n__pinterestAddToCartValues['page_title'] = n__eById('pagetitle').innerHTML; n__pinterestAddToCartValues['product_name'] = n__itemRef.n__itemTitle; n__pinterestAddToCartValues['product_id'] = n__itemRef.n__itemId; n__pinterestAddToCartValues['product_category'] = n__itemRef.n__itemType; n__pinterestAddToCartValues['product_price'] = n__itemRef.n__itemPrice; n__pinterestAddToCartValues['product_quantity'] = n__itemRef.n__itemQty; n__trackPinterestEvent( "AddToCart", n__pinterestAddToCartValues, Array() ); }catch(err){}; try{ window._learnq = window._learnq || []; //assemble klaviyo payload var n__klaviyoPayload = { "$value": n__itemRef.n__itemPrice, "AddedItem_ProductName": n__itemRef.n__itemTitle, "AddedItem_ProductID": n__itemRef.n__itemId, "AddedItem_SKU": n__itemRef.n__itemId, "AddedItem_Categories": [n__itemRef.n__itemSlug], "AddedItem_ImageURL": "http://www.smilebrilliant.com/static/images/product/"+n__itemRef.n__itemImageFull, "AddedItem_URL": "https://www.smilebrilliant.com/product/"+n__itemRef.n__itemSlug, "AddedItem_Price": n__itemRef.n__itemPrice, "AddedItem_Quantity": 1, "CheckoutURL": "https://www.smilebrilliant.com/checkout", "ItemNames": [], "Items": [] }; //requires we pass the rest of the details var n__klaviyoItems = new Array(); for(n__curProdId in n__shoppingCart.n__itemArray) { for(var i = 0; i < n__shoppingCart.n__itemArray[n__curProdId].length; i++) { if(n__shoppingCart.n__itemArray[n__curProdId][i].n__itemQty > 0) { n__itemRef = n__shoppingCart.n__itemArray[n__curProdId][i];
var n__curKlaviyoItem = { "ProductID": n__itemRef.n__itemId, "SKU": n__itemRef.n__itemId, "ProductName": n__itemRef.n__itemTitle, "Quantity": n__itemRef.n__itemQty, "ItemPrice": n__itemRef.n__itemPrice, "RowTotal": n__itemRef.n__itemPrice*n__itemRef.n__itemQty, "ProductURL": "https://www.smilebrilliant.com/product/"+n__itemRef.n__itemSlug, "ImageURL": "http://www.smilebrilliant.com/static/images/product/"+n__itemRef.n__itemImageFull, "ProductCategories": [n__itemRef.n__itemSlug] };
//push to item names n__klaviyoPayload.ItemNames.push(n__itemRef.n__itemTitle); n__klaviyoPayload.Items.push(n__curKlaviyoItem);
} } } window._learnq.push(["track", "Added to Cart", n__klaviyoPayload]);
}catch(err){}; } }
//add the item to the shopping cart n__shoppingCart.n__addToItemQty( n__productId, n__customization, 1, true, function(){} );
}
//*** BUYER FOOTPRINT START ***/ var n__buyerFootprintController = new n__buyerFootprintController();
//if we were passed a hash, then overwrite the affiliate slug var n__footprintSlugToPass = ""; if(n__affiliateSlug != "") { n__footprintSlugToPass = n__affiliateSlug; } else { //check local storage, if we have it, set as campaign slug try { if(typeof localStorage.campaignSlug != 'undefined' && localStorage.campaignSlug != "") { n__campaignSlug = localStorage.campaignSlug; n__footprintSlugToPass = n__campaignSlug;
} }catch(err){} }
//check if buyerId is known try { if(typeof localStorage.buyerId != 'undefined' && localStorage.buyerId != "") { n__buyerId = localStorage.buyerId;
//if its known, then fire multi-visitor tag try{ document.getElementById('adwordsMultiVisitorTag').src = "https://googleads.g.doubleclick.net/pagead/viewthroughconversion/991526735/?value=0¤cy_code=USD&label=tj2bCIbAvmsQz_7l2AM&guid=ON&script=0"; }catch(err){}; } }catch(err){}
//now we perform the ajax request var n__param = "href="+n__urlEncodeString(window.location.href)+"&"+ "campaignSlug="+n__urlEncodeString(n__footprintSlugToPass)+"&"+ "buyerId="+n__urlEncodeString(n__buyerId)+"&"+ "referrer=http%3A%2F%2Fwww.bing.com%2F&"+ "productId=&"+ "mode=ajax";
var n__newAjaxRequest = new n__ajaxRequest("GET", "/requests/request.buyerFootprint.php", n__param, true, true); n__newAjaxRequest.n__onResponse = function(n__responseText) {
var n__json = n__parseJSON(n__responseText);
try { if(n__json.buyerId != "") { n__buyerId = n__json.buyerId;
//set local storage localStorage.buyerId = n__buyerId; } }catch(err){}
try { if(n__json.campaignSlug != "") { n__campaignSlug = n__json.campaignSlug;
//set local storage localStorage.campaignSlug = n__campaignSlug; } }catch(err){}
//onload of script attach buyer id try { $zopim(function() { $zopim.livechat.addTags("BUYERID_"+n__buyerId); }); }catch(err){}
}; //if we hit an error, then tell the user n__newAjaxRequest.n__onError = function(n__error) { } n__newAjaxRequest.n__process();
//*** BUYER FOOTPRINT END ***/
/*** GOOGLE ANALYCIS **/ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-22471304-5', 'smilebrilliant.com'); ga('require', 'displayfeatures'); ga('require', 'ec');
ga('send', 'pageview');
//BING (function(w,d,t,r,u){var f,n,i;w[u]=w[u]||[],f=function(){var o={ti:"5992099"};o.q=w[u],w[u]=new UET(o),w[u].push("pageLoad")},n=d.createElement
//FACEBOOK PIXEL !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', '121191548558045'); fbq('track', "PageView");
//PINTEREST PIXEL try { var n__pinterestPageVisitValues = new Array(); if(n__campaignSlug != "") { n__pinterestPageVisitValues['promo_code'] = n__campaignSlug; } n__pinterestPageVisitValues['page_title'] = n__eById('pagetitle').innerHTML;
n__trackPinterestEvent( "PageVisit", n__pinterestPageVisitValues, Array() ); } catch(err){}
//GOOGLE CUSTOMER REVIEWS window.renderBadge = function() { var ratingBadgeContainer = document.createElement("div"); document.body.appendChild(ratingBadgeContainer); window.gapi.load('ratingbadge', function() { window.gapi.ratingbadge.render(ratingBadgeContainer, {"merchant_id": 101480889}); }); } function n__enableGoogleTrustedStore() { (function() { var gts = document.createElement("script"); gts.type = "text/javascript"; gts.async = true; gts.src = "https://apis.google.com/js/platform.js?onload=renderBadge"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(gts, s); })(); }
if(n__isMobile == false){n__enableGoogleTrustedStore();}
Source link