'shopify_3925753823276_29374186455084', 'shopify_3928563154988_29383198081068', 'shopify_3925834498092_29376241827884', 'shopify_3928575508524_29383256178732', 'shopify_3928563220524_29383198933036', 'shopify_3925754904620_29374255071276', 'shopify_3930234486828_29390189527084', 'shopify_3925917302828_29376399802412', 'shopify_3925816180780_29376162758700', 'shopify_3930194804780_29389973815340', 'shopify_3930194509868_29389973553196', 'shopify_3930193854508_29389972701228', 'shopify_3930193199148_29389971095596', 'shopify_3930192412716_29389969915948', 'shopify_3930192347180_29389969457196', 'shopify_3930190512172_29389966147628', 'shopify_3930186022956_29389955530796', 'shopify_3930185498668_29389954744364', 'shopify_3930184024108_29389948289068', 'shopify_3930183041068_29389946814508', 'shopify_3930182877228_29389944946732', 'shopify_3930180517932_29389936164908', 'shopify_3930180386860_29389934723116', 'shopify_3930179502124_29389931806764', 'shopify_3930178912300_29389929513004', 'shopify_3930177568812_29389922762796', 'shopify_3930176651308_29389918535724', 'shopify_3930176585772_29389917421612', 'shopify_3928606638124_29383451246636', 'shopify_3928604442668_29383448461356', 'shopify_3928603590700_29383443742764', 'shopify_3928603459628_29383441907756', 'shopify_3928602542124_29383437287468', 'shopify_3928601395244_29383431815212', 'shopify_3928600707116_29383428440108', 'shopify_3928577179692_29383264108588', 'shopify_3928576852012_29383262896172', 'shopify_3928576327724_29383259422764', 'shopify_3928574459948_29383252246572', 'shopify_3928567676972_29383217938476', 'shopify_3928566661164_29383214989356', 'shopify_3928564957228_29383205290028', 'shopify_3928564072492_29383202471980', 'shopify_3925754839084_29374235901996', 'shopify_3925753364524_29374181277740', 'shopify_3925752348716_29374178787372', 'shopify_3930241564716_29390217379884', 'shopify_3930241499180_29390216101932', 'shopify_3930238615596_29390207615020', 'shopify_3930230849580_29390158299180']; if (remarketingType == 'OTHER') { var googleTagParams = { dynx_itemid: prodIds, dynx_pagetype: 'searchresults' }; } else { var googleTagParams = { ecomm_prodid: prodIds, ecomm_pagetype: 'category' }; } var mainPageActive = false; var cartPage = { active: cartPageActive, // flag true/false // if facebookEventParams is undefined set facebookEventParams = null facebookEventParams: typeof facebookEventParams !== 'undefined' ? facebookEventParams : null, googleTagParams: typeof googleTagParams !== 'undefined' ? googleTagParams : null }; var productPage = { active: productPageActive, // flag true/false facebookEventParams: typeof facebookEventParams !== 'undefined' ? facebookEventParams : null, googleTagParams: typeof googleTagParams !== 'undefined' ? googleTagParams : null }; var collectionPage = { active: collectionPageActive, // flag true/false facebookEventParams: null, googleTagParams: typeof googleTagParams !== 'undefined' ? googleTagParams : null }; var mainPage = { active: mainPageActive, facebookEventParams: null, googleTagParams: typeof googleTagParams !== 'undefined' ? googleTagParams : null }; // here we initialize our global object which contains all necessary information for // our all scripts which fired some google or facebook analytic events etc. // we should use some unique name to identify this object to avoid names conflict // relative to other global objects var hash = 'ROIHunterEasy_5a83c915b9f3150f071dd42973557062ac2f30b295a5b6393544410da07ecb27'; window[hash] = { cartPage: cartPage, productPage: productPage, collectionPage: collectionPage, mainPage: mainPage, remarketingType: remarketingType }; // begin: initialize our rheasy_fbq object for facebook tracking window[hash].rheasy_fbq = function() { if (arguments.length === 0) { return; } var pixelId, trackType, contentObj; //get parameters: if (typeof arguments[0] === 'string') pixelId = arguments[0]; //param string PIXEL ID if (typeof arguments[1] === 'string') trackType = arguments[1]; //param string TRACK TYPE (PageView, Purchase) if (typeof arguments[2] === 'object') contentObj = arguments[2]; //param object (may be null): // {value : subtotal_price, // content_type : some_string, // currency : shop_curency, // contents : [{id, quantity, item_price}, ...] instance of array // } var argumentsAreValid = typeof pixelId === 'string' && pixelId.replace(/\s+/gi, '') !== '' && typeof trackType === 'string' && trackType.replace(/\s+/gi, '') !== ''; if (!argumentsAreValid) { console.error('RH PIXEL - INVALID ARGUMENTS'); return; } var params = []; params.push('id=' + encodeURIComponent(pixelId)); switch (trackType) { case 'PageView': case 'ViewContent': case 'Search': case 'AddToCart': case 'InitiateCheckout': case 'AddPaymentInfo': case 'Lead': case 'CompleteRegistration': case 'Purchase': case 'AddToWishlist': params.push('ev=' + encodeURIComponent(trackType)); break; default: console.error('RH PIXEL - BAD TRACKTYPE'); return; } params.push('dl=' + encodeURIComponent(document.location.href)); if (document.referrer) params.push('rl=' + encodeURIComponent(document.referrer)); params.push('if=false'); params.push('ts=' + new Date().getTime()); /* Custom parameters to string */ if (typeof contentObj === 'object') { //`contents : [{id, quantity, item_price}, ...]` to string for (var u in contentObj) { if (typeof contentObj[u] === 'object' && contentObj[u] instanceof Array) { // `[{id, quantity, item_price}, ...]` to string if (contentObj[u].length > 0) { for (var y = 0; y < contentObj[u].length; y++) { if (typeof contentObj[u][y] === 'object') { // `{id, quantity, item_price}` to string contentObj[u][y] = JSON.stringify(contentObj[u][y]); } contentObj[u][y] = (contentObj[u][y] + '') //JSON to string .replace(/^\s+|\s+$/gi, '') //delete white characterts from begin on end of the string .replace(/\s+/gi, ' ') //replace white characters inside string to ' ' } params.push('cd[' + u + ']=' + encodeURIComponent(contentObj[u].join(',') //create JSON array - [param1,param2,param3] .replace(/^/gi, '[') .replace(/$/gi, ']'))) } } else if (typeof contentObj[u] === 'string') { params.push('cd[' + u + ']=' + encodeURIComponent(contentObj[u])); } } } var imgId = new Date().getTime(); var img = document.createElement('img'); img.id = 'fb_' + imgId, img.src = 'https://www.facebook.com/tr/?' + params.join('&'), img.width = 1, img.height = 1, img.style = 'display:none;'; document.head.appendChild(img); window.setTimeout(function() { var t = document.getElementById('fb_' + imgId); t.parentElement.removeChild(t); }, 1000); }; // end of: initializing rheasy_fbq object })();