function SecurityPDFClick(){ga("send",{hitType:"event",eventCategory:"Content",eventAction:"Download",eventLabel:"Security PDF",transport:"beacon"});fbq("track","CompleteRegistration")}function BuyingGuidePDFClick(){ga("send",{hitType:"event",eventCategory:"Content",eventAction:"Download",eventLabel:"Buying Guide PDF",transport:"beacon"});fbq("track","CompleteRegistration")}function BuyingGuidePDFFormSubmit(){ga("send",{hitType:"event",eventCategory:"Content",eventAction:"Form",eventLabel:"Buying Guide PDF",transport:"beacon"});fbq("track","CompleteRegistration")}function ContactFormSubmit(){ga("send",{hitType:"event",eventCategory:"Form",eventAction:"Submit",eventLabel:"Contact Us",transport:"beacon"});fbq("track","CompleteRegistration")}function RibbonFinderFormSubmit(){ga("send",{hitType:"event",eventCategory:"Form",eventAction:"Submit",eventLabel:"Ribbon Finder",transport:"beacon"})}function PrintedCardsFormSubmit(){ga("send",{hitType:"event",eventCategory:"Form",eventAction:"Submit",eventLabel:"Printed Cards",transport:"beacon"});fbq("track","CompleteRegistration")}function PrintedLanyardsFormSubmit(){ga("send",{hitType:"event",eventCategory:"Form",eventAction:"Submit",eventLabel:"Printed Lanyards",transport:"beacon"});fbq("track","CompleteRegistration")}function PrintedWristbandsFormSubmit(){ga("send",{hitType:"event",eventCategory:"Form",eventAction:"Submit",eventLabel:"Printed Wristbands",transport:"beacon"});fbq("track","CompleteRegistration")}function ProductTitleCopied(){ga("send",{hitType:"event",eventCategory:"Content",eventAction:"Copy",eventLabel:"Product Title",transport:"beacon"})}function ProductAddedToBasket(){ga("send",{hitType:"event",eventCategory:"Product",eventAction:"Click",eventLabel:"AddToBasket",transport:"beacon"});fbq("track","AddToCart")}function EcoFriendlyFormFilled(){ga("send",{hitType:"event",eventCategory:"Form",eventAction:"Submit",eventLabel:"EcoFriendly",transport:"beacon"});fbq("track","CompleteRegistration")}function PhotoIdFormFilled(){ga("send",{hitType:"event",eventCategory:"Form",eventAction:"Submit",eventLabel:"PhotoId",transport:"beacon"});fbq("track","CompleteRegistration")}function InitiateCheckout(){fbq("track","InitiateCheckout")}function sendToAnalytics(n){dataLayer.push(n)}function ProductToGA4Product(n,t,i){var r=n.category.split("/").map(function(n){return n.trim()});return{item_id:n.id,item_name:n.name,affiliation:"",coupon:"",discount:"",index:n.position,item_brand:n.brand,item_category:r[0]||"",item_category2:r[1]||"",item_category3:r[2]||"",item_category4:r[3]||"",item_category5:r[4]||"",item_list_id:t,item_list_name:i,item_variant:"",location_id:"",price:n.price,quantity:n.quantity}}function analyticsLoggedInStatus(){$("#analytics-loggedin").data("id")>0?sendToAnalytics({event:"GAE",GAE:{category:"accounts",action:"logged in status",label:$("#analytics-loggedin").data("id")>=0},loggedIn:$("#analytics-loggedin").data("id")>=0,userID:$("#analytics-loggedin").data("id")}):sendToAnalytics({event:"GAE",GAE:{category:"accounts",action:"logged in status",label:$("#analytics-loggedin").data("id")>=0},loggedIn:$("#analytics-loggedin").data("id")>=0})}function analyticsProductRecommendations(){if($(".product-page").length>0){$(".analytics-recommendation-product").on("click",function(n){n.preventDefault();sendToAnalytics({event:"GAE",GAE:{category:"product recommendations",action:"click",label:$(this).data("sku")},recommendationParent:$(".analytics-product-page").data("id"),recommendationChild:$(this).data("sku")});window.location.href=$(n.currentTarget)[0].href});$(".add-basket-form").one("submit",function(){var n=$(this).serialize();sendToAnalytics({event:"GAE",GAE:{category:"product recommendations",action:"click",label:n.Id},recommendationParent:$(".analytics-product-page").data("id"),recommendationChild:n.Id})})}}function analyticsSignUp(){$(".analytics-registerform").one("submit",function(){$("#NewPassword").val()==$("#ConfirmPassword").val()&&sendToAnalytics({event:"GAE",GAE:{category:"accounts",action:"new account"}})})}function analyticsRibbonFinder(){$(".analytics-ribbonfinder").one("submit",function(){sendToAnalytics({event:"GAE",GAE:{category:"ribbon finder",action:"search",label:$("#RibbonVersions option:selected").text()}})})}function analyticsErrorPages(){$("title").text()=="Error404"&&sendToAnalytics({event:"GAE",GAE:{category:"site errors",action:"4xx error",label:"404"}});$("title").text()=="Error403"&&sendToAnalytics({event:"GAE",GAE:{category:"site errors",action:"4xx error",label:"403"}});$("title").text()=="General Error"&&sendToAnalytics({event:"GAE",GAE:{category:"site errors",action:"4xx error",label:"General Error"}})}function analyticsSiteSearch(){var n,t,i,r;if($(".analytics-no-results").length>0&&sendToAnalytics({event:"GAE",GAE:{category:"site search",action:"no results found",label:$(".analytics-no-results").text()}}),$(".analytics-search-impressions").length>0){sendToAnalytics({event:"GAE",numResults:$(".analytics-product").length,GAE:{category:"site search",action:"site search",label:$(".analytics-results").text().replace(/'/g,"")}});n=[];$(window).on("resize scroll load",function(){r();i()});$(".analytics-product").each(function(n,t){$(t).attr("data-position",n)});$(".analytics-product").on("click",function(n){n.preventDefault();var t=_.omit($(this).data(),"seen");u();sendToAnalytics({event:"GAE",GAE:{category:"products",action:"click"},ecommerce:{click:{actionField:{list:"search results"},products:[t]}}});window.location.href=$(n.currentTarget)[0].href});t=-1;function u(){n.length>0&&f(n.splice(0,16))}function f(n){sendToAnalytics({event:"view_item_list",ecommerce:{item_list_id:"search_products",item_list_name:"Search Products",items:[n.map(n=>ProductToGA4Product(n,"search_products","Search Products"))]}})}i=_.throttle(u,4e3);r=_.throttle(function(){if($(window).scrollTop()>t){t=$(window).scrollTop();var i=$(window).scrollTop()+$(window).height();$(".analytics-product").filter(function(){return $(this).attr("data-seen")!="true"&&$(this).offset().top+$(this).outerHeight()<i}).each((t,i)=>{$(i).attr("data-seen","true");var r=_.omit($(i).data(),"seen");r.list="search results";n.push(r)})}n.length>16&&f(n.splice(0,16))},0)}}function analyticsCategorySearch(){var n,t,i,r;if($(".analytics-empty-category").length>0&&sendToAnalytics({event:"GAE",GAE:{category:"product categories",action:"no items found in category",label:$(".analytics-category-title").text(),numResults:0}}),$(".analytics-category-impressions").length>0){sendToAnalytics({event:"GAE",numResults:$(".analytics-product").length,GAE:{category:"product categories",action:"product categories",label:$(".analytics-category-title").text()}});n=[];$(window).on("resize scroll load",function(){r();i()});$(".analytics-product").each(function(n,t){$(t).attr("data-position",n)});$(".analytics-product").on("click",function(n){n.preventDefault();var t=_.omit($(this).data(),"seen");u();sendToAnalytics({event:"GAE",GAE:{category:"products",action:"click"},ecommerce:{click:{actionField:{list:"category"},products:[t]}}});window.location.href=$(n.currentTarget)[0].href});t=-1;function u(){n.length>0&&f(n.splice(0,16))}function f(n){sendToAnalytics({event:"view_item_list",ecommerce:{item_list_id:"category_products",item_list_name:"Category Products",items:[n.map(n=>ProductToGA4Product(n,"category_products","Category Products"))]}})}i=_.throttle(u,4e3);r=_.throttle(function(){if($(window).scrollTop()>t){t=$(window).scrollTop();var i=$(window).scrollTop()+$(window).height();$(".analytics-product").filter(function(){return $(this).attr("data-seen")!="true"&&$(this).offset().top+$(this).outerHeight()<i}).each((t,i)=>{$(i).attr("data-seen","true");var r=_.omit($(i).data(),"seen");r.category=$(".breadcrumb").text().replace(/\s+/g," ").trim().replace(/>/g,"/");r.list="category page";n.push(r)})}n.length>16&&f(n.splice(0,16))},0)}}function analyticsProductPage(){if($(".analytics-product-page").length>0){var n=$(".analytics-product-page").first().data();sendToAnalytics({event:"view_item",ecommerce:{currency:"GBP",value:n.price,items:[ProductToGA4Product(n,"product_page","Product Page")]}});$(".pdp-tab").on("click",function(){sendToAnalytics({event:"GAE",GAE:{category:"product tabs",action:"click",label:$(this).attr("title")}})});$(".add-basket").on("click",function(){var t=ProductToGA4Product(n,"checkout_products","Checkout Products");t.quantity=$("#product-quantity").prop("value");sendToAnalytics({event:"add_to_cart",ecommerce:{currency:"GBP",value:n.price,items:[t]}})})}}function analyticsBasket(){$(".analytics-updateform").one("submit",function(){var n=$(this).find('input[name="qty"]').first().prop("value")-$(this).data("quantity"),t=$(this).data(),i=ProductToGA4Product(t,"cart_products","Cart Products");i.quantity=n;n>0?sendToAnalytics({event:"add_to_cart",ecommerce:{currency:"GBP",value:t.price,items:[i]}}):n<0&&sendToAnalytics({event:"remove_from_cart",ecommerce:{currency:"GBP",value:t.price,items:[i]}})});$(".analytics-deleteform").one("submit",function(){sendToAnalytics({event:"GAE",GAE:{category:"basket",action:"remove from basket"},ecommerce:{remove:{products:[$(this).data()]}}})});$(".ga-initiate-checkout").on("click",function(n){n.preventDefault();var t=$(".analytics-updateform").map(function(n,t){return $(t).data()}).get(),i=t.map(n=>ProductToGA4Product(n,"checkout_products","Checkout Products"));sendToAnalytics({event:"begin_checkout",ecommerce:{currency:"GBP",value:$(".analytics-basketsubtotal").text().split(" ")[0].replace(" ",""),coupon:"",items:[i]}});window.location.href=$(n.currentTarget)[0].href})}function analyticsBasketOverview(){$("#guest-checkout-link").length>0&&sendToAnalytics({event:"GAE",ecommerce:{checkout_option:{actionField:{step:1}}}});$("#guest-checkout-link").on("click",function(n){n.preventDefault();sendToAnalytics({event:"GAE",ecommerce:{checkout_option:{actionField:{step:1,option:"GUEST"}}}});window.location.href=$(n.currentTarget)[0].href});$("#login-form").one("submit",function(){sendToAnalytics({event:"GAE",ecommerce:{checkout_option:{actionField:{step:1,option:"LOGIN"}}}})})}function analyticsContactDetails(){if($(".analytics-contact-details").length>0){var n=window.analyticsCart;sendToAnalytics({event:"GAE",GAE:{category:"checkout",action:"step 2"},ecommerce:{checkout:{actionField:{step:2,option:""},products:_.map(n,function(n){return _.omit(n,"position")})}}})}}function analyticsDeliveryDetails(){var r;if($(".analytics-delivery-details").length>0){var n=window.analyticsCart,t=window.analyticsShipingRates,i="";Array.isArray(t)&&t.forEach(n=>$(".ShippingMethod-"+n.Code).change(function(){i=n.Code;sendToAnalytics({event:"GAE",ecommerce:{delivery_option:{actionField:{step:3,option:[n.Code]}}}})}));r=n.map(n=>ProductToGA4Product(n,"shipping_products","Shipping Products"));sendToAnalytics({event:"GAE",GAE:{category:"checkout",action:"step 3"},ecommerce:{checkout:{actionField:{step:3,option:""},products:_.map(n,function(n){return _.omit(n,"position")})}}})}}function analyticsPaymentOptions(){var t,n;if($(".analytics-payment-options").length==1){t=window.analyticsCart;sendToAnalytics({event:"GAE",GAE:{category:"checkout",action:"step 4"},ecommerce:{checkout:{actionField:{step:4,option:""},products:_.map(t,function(n){return _.omit(n,"position")})}}});n=!1;$("#PaymentSagepay").change(function(){n=!0;sendToAnalytics({event:"checkoutOption",ecommerce:{checkout_option:{actionField:{step:4,option:["Sagepay"]}}}})});$("#PaymentPaypal").change(function(){n=!0;sendToAnalytics({event:"checkoutOption",ecommerce:{checkout_option:{actionField:{step:4,option:["Paypal"]}}}})});$("#PaymentOnAccount").change(function(){n=!0;sendToAnalytics({event:"checkoutOption",ecommerce:{checkout_option:{actionField:{step:4,option:["Account"]}}}})});$("#payment-options-form").one("submit",function(){n||sendToAnalytics({event:"checkoutOption",ecommerce:{checkout_option:{actionField:{step:4,option:["Sagepay"]}}}})})}}function analyticsContactUs(){$(".analytics-contact-us").one("submit",function(){sendToAnalytics({event:"GAE",GAE:{category:"forms",action:"submit",label:"contact us"}})})}function analyticsRequestSample(){$(".analytics-request-sample").one("submit",function(){sendToAnalytics({event:"GAE",GAE:{category:"forms",action:"submit",label:"sample request"}})})}function analyticsLostBaskets(){$(".analytics-basketsubtotal").length>0&&sendToAnalytics({event:"lostBasketEvent",lostBasket:$(".analytics-basketsubtotal").text().replace("ex. VAT","").replace(/[^0-9.]/g,"")});$(".analytics-accomplished").length>0&&sendToAnalytics({event:"lostBasketEvent",lostBasket:undefined})}$(document).ready(function(){$(document).on("click",".ga-pdf-buying-guide",BuyingGuidePDFClick);$(document).on("click",".ga-pdf-security-guide",SecurityPDFClick);$(document).on("submit",".ga-form-contact-us",ContactFormSubmit);$(document).on("submit",".ga-form-ribbon-finder",RibbonFinderFormSubmit);$(document).on("submit",".ga-form-printed-wristbands",PrintedWristbandsFormSubmit);$(document).on("submit",".ga-form-printer-guide",BuyingGuidePDFFormSubmit);$(document).on("copy","#product-title",ProductTitleCopied);$(document).on("submit",".ga-eco-friendly-form",EcoFriendlyFormFilled);$(document).on("submit",".ga-photo-id-form",PhotoIdFormFilled);$(document).on("click",".ga-add-to-basket",ProductAddedToBasket);$(document).on("click",".ga-initiate-checkout",InitiateCheckout)});$(document).ready(function(){analyticsLoggedInStatus();analyticsErrorPages();analyticsSignUp();analyticsProductRecommendations();analyticsRibbonFinder();analyticsSiteSearch();analyticsCategorySearch();analyticsProductPage();analyticsBasket();analyticsBasketOverview();analyticsContactDetails();analyticsDeliveryDetails();analyticsPaymentOptions();analyticsContactUs();analyticsLostBaskets()})