function SendEventAnalytics(t,e){
	if (ME && ME.marketingEvents) {
        var n = ME.marketingEvents;
        if (n[t])
            for (var i = 0, r = n[t].length; i < r; ++i) {
                var o = n[t][i];
                e = Array.isArray(e) ? e : [e];
                try {
                    o.apply(null, e);
                } catch (t) {
                    console.log(t);
                }
            }
    }
}



(function (w) {
    w.ME = {
       
        marketingEvents: {

        "view_m.item":[
          	function (m) {
          		
          		console.log(m);
          		
        		try {
	        	gtag('event', 'view_m.item', {
				    'currency': CURRENCY_INFO.code,
				    'value': m.item.price,
				    'm.items': [
				        {
				            'm.item_id': m.item.inner_num,
				            'm.item_name': m.item.caption,
				            'm.item_brand': m.item.brand_caption,
				            'm.item_category': m.item.parent_category_info.caption,
				            'price': m.item.price
				        }
				    ],
				    'ecomm_prodid': 'LMB-2009-1000',
				    'ecomm_pagetype': m.item.inner_num,
				    'ecomm_totalvalue': m.item.price
				});
				} catch(e) {
	                //console.error(e);
	            }
        	},
        	function (m){
        		try {
        			fbq('track', 'ViewContent',{
        				
                        content_name: m.item.caption,
                        content_category: m.item.parent_category_info.caption, 
                        content_brand: m.item.brand_caption,
                        content_type: 'product',
                        currency: GLOBAL.CURRENCY_INFO.code,
                        value: m.item.price
                    	},
                    	{eventID: eventId}
        				);

        		} catch(e) {
	                //console.error(e);
	            }
        	}
        ],
        "add_cart_item":[
          	function (m) {
        		try {
		        	gtag('event', 'add_to_cart', {
			            'currency': CURRENCY_INFO.code,
			            'value': m.item.price*m.item.cnt ,
			            'm.items': [
			                {
			                    'm.item_id': m.item.inner_num,
			                    'm.item_name': m.item.caption,
			                    "m.item_brand": m.item.brand_caption,
			                    'price': m.item.price,
			                    'quantity': m.item.cnt 
			                    
			                }
			            ]

			        });
				} catch(e) {
	                //console.error(e);
	            }
        	},
        	function (m){
        		console.log(m.item.cnt*m.item.price);
        		try {
        			(function () {
                		var products = null;
                
                		fbq('track', 'AddToCart', {
	                        contents: [
	                            {
	                                'id': m.item.inner_num,
	                                'quantity': m.item.cnt,
	                                'm.item_price': m.item.price * 1
	                            }
	                        ],
	                        content_type: 'product',
	                        currency: GLOBAL.CURRENCY_INFO.code,
	                        value: m.item.quantity * m.item.price 
                    		},
                    		{eventID: eventId}
					   		);
						})();

        		} catch(e) {
	                //console.error(e);
	            }
        	}
        ],
        "remove_cart_item":[
          	function (m) {
          		console.log(m.item);
        		try {
		        	gtag("event", "remove_from_cart", {
						  currency: GLOBAL.CURRENCY_INFO.code,
						  value: 7.77,
						  items: [
						    {
						      item_id: "SKU_12345",
						      item_name: "Stan and Friends Tee",
						      affiliation: "Google Merchandise Store",
						      coupon: "SUMMER_FUN",
						      discount: 2.22,
						      index: 0,
						      item_brand: "Google",
						      item_category: "Apparel",
						      item_category2: "Adult",
						      item_category3: "Shirts",
						      item_category4: "Crew",
						      item_category5: "Short sleeve",
						      item_list_id: "related_products",
						      item_list_name: "Related Products",
						      item_variant: "green",
						      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
						      price: 9.99,
						      quantity: 1
						    }
						  ]
						});
				} catch(e) {
	                //console.error(e);
	            }
        	}
        ],
        "search":[
          	function (m) {
          		
        		try {
		        	gtag("event", "search", {
					  search_term: "m.search_term"
					});
				} catch(e) {
	                console.error(e);
	            }
        	}
        ],
        "view_cart":[
          	function (m) {
        		try {
		        	gtag("event", "view_cart", {
					  currency: GLOBAL.CURRENCY_INFO.code,
					  value: 7.77,
					  items: [
					    {
					      item_id: "SKU_12345",
					      item_name: "Stan and Friends Tee",
					      affiliation: "Google Merchandise Store",
					      coupon: "SUMMER_FUN",
					      discount: 2.22,
					      index: 0,
					      item_brand: "Google",
					      item_category: "Apparel",
					      item_category2: "Adult",
					      item_category3: "Shirts",
					      item_category4: "Crew",
					      item_category5: "Short sleeve",
					      item_list_id: "related_products",
					      item_list_name: "Related Products",
					      item_variant: "green",
					      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
					      price: 9.99,
					      quantity: 1
					    }
					  ]
					});
				} catch(e) {
	                //console.error(e);
	            }
        	}
        ],
        "purcahse":[
          	function (m) {
        		try {
		        	gtag("event", "purchase", {
					    transaction_id: "T_12345",
					    value: 25.42,
					    tax: 4.90,
					    shipping: 5.99,
					    currency: GLOBAL.CURRENCY_INFO.code,
					    coupon: "SUMMER_SALE",
					    items: [
					     {
					      item_id: "SKU_12345",
					      item_name: "Stan and Friends Tee",
					      affiliation: "Google Merchandise Store",
					      coupon: "SUMMER_FUN",
					      discount: 2.22,
					      index: 0,
					      item_brand: "Google",
					      item_category: "Apparel",
					      item_category2: "Adult",
					      item_category3: "Shirts",
					      item_category4: "Crew",
					      item_category5: "Short sleeve",
					      item_list_id: "related_products",
					      item_list_name: "Related Products",
					      item_variant: "green",
					      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
					      price: 9.99,
					      quantity: 1
					    },
					    {
					      item_id: "SKU_12346",
					      item_name: "Google Grey Women's Tee",
					      affiliation: "Google Merchandise Store",
					      coupon: "SUMMER_FUN",
					      discount: 3.33,
					      index: 1,
					      item_brand: "Google",
					      item_category: "Apparel",
					      item_category2: "Adult",
					      item_category3: "Shirts",
					      item_category4: "Crew",
					      item_category5: "Short sleeve",
					      item_list_id: "related_products",
					      item_list_name: "Related Products",
					      item_variant: "gray",
					      location_id: "ChIJIQBpAG2ahYAR_6128GcTUEo",
					      price: 20.99,
					      promotion_id: "P_12345",
					      promotion_name: "Summer Sale",
					      quantity: 1
					    }]
					});
				} catch(e) {
	                //console.error(e);
	            }
        	}
        ]

    }
    }
})(window);

function isEmpty(obj) {
    return Object.keys(obj).length === 0;
}




function gtag_report_conversion($form_type, url = null, ...args) {
    var params = {}
    switch ($form_type) {
        case 'callback':
            var id = '';
            break;
        case 'feedback':
            var id = '';
            break;
        case 'consultant':
            var id = '';
            break;
        case 'download':
            var id = '';
            /*'event_category': 'File Download','event_label': 'My File.pdf'*/
            break;
        case 'phone1':
            var id = '';
            /*phone_conversion_number': '1234567890' */
            break;
        case 'phone2':
            var id = '';
            /*phone_conversion_number': '1234567890' */
            break;
        case 'mail_click':
            var id = '';
            /*phone_conversion_number': '1234567890' */
            break;
        case 'get_price':
            var id = '';

            break;

        default:

    }
    var callback = function() {
        if (url !== null) {
            window.location = url;
        }
    };

    var eventData = {
        'send_to': id
    };

    if (url !== null) {
        eventData.url = url;
    }
    var combinedData = {
        ...eventData,
        ...args[0]
    };
    gtag('event', 'conversion', combinedData);

    return false;
}
