function fbViewContent(params) { if (typeof fbq === "function") { fbq('track', 'ViewContent', { value: params['value'], currency: ((params['currency'] !== undefined) ? params['currency'] : 'USD'), content_ids: params['content_ids'], content_type: params['content_type'] }); } //alert('ViewContent: '+params['content_ids']+' '+params['content_type']); } function fbAddToCart(params) { if (typeof fbq === "function") { fbq('track', 'AddToCart', { value: params['value'], currency: ((params['currency'] !== undefined) ? params['currency'] : 'USD'), content_ids: params['content_ids'], content_type: params['content_type'] }); } //alert('AddToCart: '+params['content_ids']+' '+params['content_type']); } function fbAddToWishlist(params) { if (typeof fbq === "function") { fbq('track', 'AddToWishlist', { value: params['value'], currency: ((params['currency'] !== undefined) ? params['currency'] : 'USD'), content_ids: params['content_ids'], content_type: params['content_type'] }); } //alert('AddToWishlist: '+params['content_ids']+' '+params['content_type']); } function fbInitiateCheckout(params) { if (typeof fbq === "function") { fbq('track', 'InitiateCheckout', { value: params['value'], currency: ((params['currency'] !== undefined) ? params['currency'] : 'USD') }); } //alert('InitiateCheckout'); } function fbPurchase(params) { let mainItems = params['contents'].split('%/'); let items = []; mainItems.forEach(function(item) { let itemArray = item.split(','); items.push({ id: itemArray[0], quantity: itemArray[1], }) }); if (typeof fbq === "function") { fbq('track', 'Purchase', { value: params['value'], currency: ((params['currency'] !== undefined) ? params['currency'] : 'USD'), contents: items, content_type: params['content_type'] }); console.log('fbq Purchase event called'); } } function fbLead(params) { if (typeof fbq === "function") { fbq('track', 'Lead', { value: 1, currency: ((params['currency'] !== undefined) ? params['currency'] : 'USD'), }); } //alert('Lead'); } function fbCompleteRegistration(params) { if (typeof fbq === "function") { fbq('track', 'CompleteRegistration', { value: 1, currency: ((params['currency'] !== undefined) ? params['currency'] : 'USD'), }); } //alert('CompleteRegistration'); } function fbSearch(params) { if (typeof fbq === "function") { fbq('track', 'Search', { search_string: params['search_string'] }); } //alert('Search: '+params['search_string']); }