3-Month Survival Food Kit

[]
{let options = {};if (beacon) {options = { method: ‘beacon’ };}edgetag(‘tag’, name, payload, {}, options);};const sendUser = (user) => {if (!user || !Object.keys(user).length) {return;}edgetag(‘data’, user);};const getUser = (form, selectors) => {const user = {};if (!selectors) {return user;}Object.entries(selectors).forEach(([userKey, selector]) => {if (!selector || selector.length === 0) {return;}const selectorArray = Array.isArray(selector) ? selector : [selector];for (const selector of selectorArray) {if (!selector) {continue;}const inputUserValue = form.querySelector(selector);const userValue = (inputUserValue && inputUserValue.value) || ”;if (userValue) {user[userKey] = userValue;break;}}});return user;};const getLocalCurrency = () => {if (window.Shopify && window.Shopify.currency && window.Shopify.currency.active) {return window.Shopify.currency.active.toUpperCase();}return ‘USD’;};const newsletterFormSelectors = [‘#ContactFooter’,’.klaviyo-form’,’#wisepops-root’,’#contact_form’,’form[id*=”newsletter” i]’,’form[id*=”subscribe” i]’,’form.ml-block-form’];const newsletterForm = newsletterFormSelectors.join(‘,’);const actions = [{selectors: [‘[type=”submit”]’, ‘form[action=”/account/login”]’],length: 2,fun: (ele) => {const user = getUser(ele, {email: ‘input[type=”email”]’});sendUser(user);},current: 0},{selectors: [‘[type=”submit”]’, ‘form[action=”/account”]’],length: 2,fun: (ele) => {let user = getUser(ele, {email: ‘input[type=”email”]’,phone: ‘input[type=”tel”]’,firstName: ‘input[name*=”first” i]:not([type=”hidden” i])’,lastName: ‘input[name*=”last” i]:not([type=”hidden” i])’});if (!user.firstName && !user.lastName) {user = {…user,…getUser(ele, { firstName: ‘input[name*=”name” i]’ })};}sendUser(user);edgetag(‘tag’, ‘CompleteRegistration’);},current: 0},{selectors: [‘[type=”submit”]’, newsletterForm],length: 2,fun: (ele) => {const user = getUser(ele, {email: [‘input[type=”email”]’, ‘input[name*=”email” i]:not([type=”hidden” i]’],phone: [‘input[type=”tel”]’, ‘input[name*=”phone” i]:not([type=”hidden” i]’],firstName: ‘input[name*=”name” i]:not([type=”hidden” i]’,dateOfBirth: ‘input[name*=”birthday” i]:not([type=”hidden” i]’});sendUser(user);edgetag(‘tag’, ‘Subscribe’, {}, {}, { method: ‘beacon’ });},current: 0},{selectors: [‘button’, newsletterForm],length: 2,fun: (ele) => {const user = getUser(ele, {email: [‘input[type=”email”]’, ‘input[name*=”email” i]:not([type=”hidden” i]’],phone: [‘input[type=”tel”]’, ‘input[name*=”phone” i]:not([type=”hidden” i]’],firstName: ‘input[name*=”name” i]:not([type=”hidden” i]’,dateOfBirth: ‘input[name*=”birthday” i]:not([type=”hidden” i]’});sendUser(user);edgetag(‘tag’, ‘Subscribe’, {}, {}, { method: ‘beacon’ });},current: 0},{selectors: [‘[type=”submit”]’, ‘form[action^=”/contact”]’],length: 2,fun: (ele) => {const user = getUser(ele, {email: [‘input[type=”email”]’, ‘input[name*=”email” i]:not([type=”hidden” i]’],phone: [‘input[type=”tel”]’, ‘input[name*=”phone” i]:not([type=”hidden” i]’],firstName: [‘input[name*=”first” i]:not([type=”hidden” i]’, ‘input[name*=”name” i]:not([type=”hidden” i]’, ‘input[name*=”nom” i]:not([type=”hidden” i]’],lastName: ‘input[id*=”last” i]:not([type=”hidden” i]’});sendUser(user);edgetag(‘tag’, ‘Contact’);},current: 0}];const resetActions = () => {for (let i = 0; i {if (!element || element.nodeName === ‘BODY’) {resetActions();return}if (element.nodeName !== ‘DIV’ && element.nodeName !== ‘INPUT’ && element.nodeName !== ‘A’ && element.nodeName !== ‘BUTTON’ && element.nodeName !== ‘FORM’) {checkElement(element.parentElement);return}for (let i = 0; i {const isDuplicate = () => {if (!cartProcessedItems || !Array.isArray(cartProcessedItems) || !cartProcessedItems.length) {return false;}const currentTimestamp = Date.now();cartProcessedItems = cartProcessedItems.filter(item => (currentTimestamp – item.timestamp) item.payload === payloadString && item.requestType !== requestType);} catch {return false;}};if (!payload || !Array.isArray(payload) || !payload.length) {return;}if (!requestType) {console.error(“[EdgeTag] Request Type is missing in sendData”);}if (isDuplicate()) {return;}payload.forEach(item => {if (item.price == null || item.price === “” || !item.id) {return;}edgetag(‘tag’, ‘AddToCart’, {currency: getLocalCurrency(),value: parseFloat(item.price) / 100,contents: [{id: item.product_id?.toString(),variantId: item.variant_id?.toString(),sku: item.sku,quantity: 1,item_price: parseFloat(item.price) / 100,title: item.title,category: item.product_type,image: item.image,brand: item.vendor,url: window.origin + item.url,type: ‘product’,}]}, {}, { method: ‘beacon’ });});cartProcessedItems.push({requestType,payload: JSON.stringify(payload),timestamp: Date.now()});};const networkListener = function() {const fetch = window.fetch; window.fetch = function() { return fetch.apply(this, Array.prototype.slice.call(arguments)).then(function(t) { if (!t || !t.ok || !t.url) {return t; } try {if (t.url.indexOf(“/cart/add”) !== -1) {const myResponse = t.clone();Promise.resolve(myResponse.json()).then(e => {if (!e) {return;}const payload = e.items ? e.items : [e];sendCartData(payload, ‘fetch’);});return t;} } catch (e) { } return t; }); };const origOpen = XMLHttpRequest.prototype.open;XMLHttpRequest.prototype.open = function() {this.addEventListener(‘load’, function() {if (!this._url) {return;}if (this._url.indexOf(“/cart/add”) !== -1) {try {const e = JSON.parse(this.responseText);if (!e) {return;}const payload = e.items ? e.items : [e];sendCartData(payload, ‘XMLHttpRequest’);} catch (e) {}return;}});origOpen.apply(this, arguments);};};networkListener();edgetag(‘tag’, ‘PageView’);const current = {“id”:40388560814165,”title”:”Default Title”,”option1″:”Default Title”,”option2″:null,”option3″:null,”sku”:”2058″,”requires_shipping”:true,”taxable”:true,”featured_image”:null,”available”:true,”name”:”3-Month Survival Food Kit”,”public_title”:null,”options”:[“Default Title”],”price”:69995,”weight”:40415,”compare_at_price”:null,”inventory_management”:null,”barcode”:”810026144936″,”requires_selling_plan”:false,”selling_plan_allocations”:[{“price_adjustments”:[{“position”:1,”price”:66495}],”price”:66495,”compare_at_price”:69995,”per_delivery_price”:66495,”selling_plan_id”:5008883797,”selling_plan_group_id”:”44d12b8db8104584d7d07c5390f6a8a2e82f9b59″},{“price_adjustments”:[{“position”:1,”price”:66495}],”price”:66495,”compare_at_price”:69995,”per_delivery_price”:66495,”selling_plan_id”:5008916565,”selling_plan_group_id”:”44d12b8db8104584d7d07c5390f6a8a2e82f9b59″},{“price_adjustments”:[{“position”:1,”price”:66495}],”price”:66495,”compare_at_price”:69995,”per_delivery_price”:66495,”selling_plan_id”:5008949333,”selling_plan_group_id”:”44d12b8db8104584d7d07c5390f6a8a2e82f9b59″},{“price_adjustments”:[{“position”:1,”price”:66495}],”price”:66495,”compare_at_price”:69995,”per_delivery_price”:66495,”selling_plan_id”:5009408085,”selling_plan_group_id”:”44d12b8db8104584d7d07c5390f6a8a2e82f9b59″}],”quantity_rule”:{“min”:1,”max”:null,”increment”:1}};edgetag(‘tag’, ‘ViewContent’, {currency: getLocalCurrency(),value: current.price / 100,contents: [{id: ‘2693988057173’,variantId: current.id.toString(),sku: current.sku,quantity: 1,item_price: current.price / 100,title: current.name,category: ‘3 Month Emergency Food Supplies’,brand: ‘4Patriots’,image: ‘https://4patriots.com/cdn/shop/files/ARRAY-3MO-72HRx2-WB.png?v=1699626278’,url: ‘https://4patriots.com/products/3-month-survival-food-kit?variant=40388560814165’,type: ‘product’,}],});window.addEventListener(‘load’, () => {document.addEventListener(‘click’, (e) => {checkElement(e.target);});});if (window.location.pathname.startsWith(‘/search’) ||window.location.pathname.startsWith(‘/pages/search-results-page’)) {const searchParams = new URLSearchParams(window.location.search);const search = searchParams.get(‘q’);if (search) {edgetag(‘tag’, ‘Search’, { search });}}window.addEventListener(‘message’,(event) => {if (event.origin !== ‘https://creatives.attn.tv’) {return;}if (!event.data || !event.data.__attentive) {return;}try {const data = event.data.__attentive;if (!data.action || !data.action.includes(‘LEAD’)) {return;}const user = {};if(data.email) {user.email = data.email;}if(data.phone) {user.phone = data.phone.replace(/[^0-9]/g, ”);}sendUser(user);edgetag(‘tag’, ‘Subscribe’);} catch (e) {console.log(“[Edgetag]”, e);}},false);window.addEventListener(‘message’, (event) => {if(!event || !event.origin || !event.data || !event.origin.includes(‘postscript’)) {return;}if (event.data.hasOwnProperty(‘CollectedEmailEvent’) && event.data.CollectedEmailEvent.email) {sendUser({ email: event.data.CollectedEmailEvent.email });edgetag(‘tag’, ‘Subscribe’);}});window.juapp = window.juapp||function(){(window.juapp.q=window.juapp.q||[]).push(arguments)};juapp(“trackFunc”, “engagement”, function(email, eventname, promotitle, cmid, options, form) {if (!email) {return;}const userData = { email };form.forEach((item) => {if (item.name === “phone_number” && item.value) {userData[“phone”] = item.value;}});edgetag(“data”, userData);edgetag(“tag”, “Subscribe”);});}();]]> 3-Month Survival Food Kit | 4Patriots

Source

You May Also Like

Leave a Reply

Your email address will not be published. Required fields are marked *